Package: bash
Version: 4.3-12

bash returns true on [ -n "$@" ] even when the scrpit/function is called
without any arguments. despite this (from man bash):
>               When  there  are no positional parameters, "$@" and $@ expand to
>               nothing (i.e., they are removed).
example:
>01:22:20 363 ~$ cat /tmp/test 
#!/bin/bash
echo -e "\$@=<$@>"
[ -n "$@" ] && echo "[ -n \"\$@\" ] is true!"
>01:22:22 363 ~$ /tmp/test 
$@=<>
[ -n "$@" ] is true!
>01:22:27 363 ~$ /tmp/test 111
$@=<111>
[ -n "$@" ] is true!
although [ -z "$@" ] works as expected.
-n also works fine with any other undeclared/null variable

Reply via email to