Emanuele Tomasi wrote: > $> /usr/bin/test -n $casa && echo yes || echo no > yes > > $> /usr/bin/test $casa && echo yes || echo no > no > > $> /usr/bin/test -z $casa && echo yes || echo no > yes
I think you may not be understanding the fact that the shell expands $casa into the empty string before invoking test, effectively swallowing it, thus the above are equivalent to: $ /usr/bin/test -n; echo $? 0 $ /usr/bin/test; echo $? 1 $ /usr/bin/test -z; echo $? 0 That is, the test program does not see any STRING argument at all. If you want to test an empty string you have to explicitly quote it in the shell so that an empty argument is actually passed to the program being invoked. Then you get the expected behavior: $ /usr/bin/test -n "$casa"; echo $? 1 $ /usr/bin/test "$casa"; echo $? 1 $ /usr/bin/test -z "$casa"; echo $? 0 You might have also seen the idiom 'test "x$foo" = x' which is another way of dealing with this problem, as well as several others such the case when $foo is "=" or a value that starts with a dash. Brian _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
