'test' utility behavior question.
Oleksandr Gavenko
gavenkoa@gmail.com
Mon Aug 30 17:32:00 GMT 2010
$ /bin/test -d && echo ok
ok
$ /bin/test -d '' && echo ok || echo must_be_error
must_be_error
POSIX require argument for -d, so behavior implementation
depend.
I can not check another 'test' implementation now.
For me get error is more convenient,
because this not break this code if $dir not defined:
if [ -d $dir ]; then
do-good-job;
else
info-user-about-missing-dir;
fi
To resolve upper code I rewrite condition in POSIX compatible form:
[ -d "$dir" ]
--
Best regards!
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list