help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Bash - variable identifier with "-"


From: Felipe Salvador
Subject: [Help-bash] Bash - variable identifier with "-"
Date: Wed, 4 Apr 2018 20:09:59 +0200
User-agent: NeoMutt/20170113 (1.7.2)

Hi,
I have this code

--
#!/bin/bash
set -x

list="dragon cvlc rhythmbox totem-audio-preview radiotray"

for p in $list
do
    which $p 1>/dev/null
    yesno=$?
    if [ "$yesno" -ne 0 ]; then
        declare $p="NO"; else
        declare $p="SÌ"
    fi
done

cat<<EOF  

    Utilizzo: $(basename $0) [OPZIONE]

    OPZIONI SUPPORTATE:                         INSTALLATO:

    -dp     Utilizza Dragonplayer               $dragon
    -vp     Utilizza (c)VLC                     $cvlc
    -rp     Utilizza Rhythmbox                  $rhythmbox
    -tp     Utilizza totem-audio-preview        $totem-audio-preview
    -rtp    Utilizza radiotray                  $radiotray

EOF
--

It return

--
+ list='dragon cvlc rhythmbox totem-audio-preview radiotray'
+ for p in $list
+ which dragon
+ yesno=0
+ '[' 0 -ne 0 ']'
+ export dragon=SÌ
+ dragon=SÌ
+ for p in $list
+ which cvlc
+ yesno=0
+ '[' 0 -ne 0 ']'
+ export cvlc=SÌ
+ cvlc=SÌ
+ for p in $list
+ which rhythmbox
+ yesno=1
+ '[' 1 -ne 0 ']'
+ export rhythmbox=NO
+ rhythmbox=NO
+ for p in $list
+ which totem-audio-preview
+ yesno=1
+ '[' 1 -ne 0 ']'
+ export totem-audio-preview=NO
/home/felipe/prog: riga 11: export: "totem-audio-preview=NO": non è un 
identificatore valido
+ for p in $list                                                    ^^^
+ which radiotray                                                   not valid 
identifier
+ yesno=1
+ '[' 1 -ne 0 ']'
+ export radiotray=NO
+ radiotray=NO
+ cat
++ basename /home/felipe/prog

    Utilizzo: prog [OPZIONE]

    OPZIONI SUPPORTATE:                         INSTALLED:

    -dp     Utilizza Dragonplayer               SÌ
    -vp     Utilizza (c)VLC                     SÌ
    -rp     Utilizza Rhythmbox                  NO
    -tp     Utilizza totem-audio-preview        -audio-preview
    -rtp    Utilizza radiotray                  NO
--

For what I understand[¹] there is no way to get it work, due to the
identifier "naming design". I'm wrong? Please, tell me there is a way
to get out form this situation. 

Tia


[¹] http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html

Regards 
-- 
Felipe Salvador



reply via email to

[Prev in Thread] Current Thread [Next in Thread]