This is the mail archive of the
cygwin
mailing list for the Cygwin project.
'test' utility behavior question.
- From: Oleksandr Gavenko <gavenkoa at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 30 Aug 2010 20:27:52 +0300
- Subject: 'test' utility behavior question.
$ /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