Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Problems with Parameter Expansion :=



Hi there again,

my second problem is that I want to set NAME to WORD,
if NAME is not set, example from zsh.info:
${NAME:=WORD}

my script (called script.sh):
-- begin --
if [ ${NAME:=`hostname | cut -c5-8`} ]
then
        echo $NAME
fi

if [ ${NAME1:=""} = "true" ]
then
        echo "true"
fi
-- end --
asuming, my hosts name is exploding:

$ echo $NAME
zsh: NAME: parameter not set
$ echo $NAME1
zsh: NAME1: parameter not set
$ . script.sh
odin
script.sh:6: parse error: condition expected: =

Again, it runs with bash and ksh.

Why does it not expand NAME1 to "" ?
running it with set -x it shows:
$ . script.sh
+-zsh:8> . script.sh
+script.sh:1> [ odin ]
+script.sh:3> echo odin
odin
+script.sh:6> [ = true ]
script.sh:6: parse error: condition expected: =

Any ideas?

Thanks for our help.

Regards

Heinrich



Messages sorted by: Reverse Date, Date, Thread, Author