hi I have this code
a="a b c"
set -- $a
if [ "$@" = "" ] ; then
echo empty
fi
why is it line 3 reports "test: [: too many arguments"? :wall:
Thanks!
hi I have this code
a="a b c"
set -- $a
if [ "$@" = "" ] ; then
echo empty
fi
why is it line 3 reports "test: [: too many arguments"? :wall:
Thanks!
a="a b c"
set -- ${a}
[[ "x${@}" == "x" ]] && echo empty
nice, just need to double the '[' and ']' and no need for the 'x'
thanks!
Use $* instead of $@ :
a="a b c"
set -- $a
if [ "$*" = "" ] ; then
echo empty
fi
Jean-Pierre.
That works in ksh and bash, but not in other Posix shells and you should use double == then..
I would use:
if [ $# -eq 0 ] ; then