On 2010-08-30 20:31, Eric Blake wrote:
On 08/30/2010 11:27 AM, Oleksandr Gavenko wrote:
$ /bin/test -d && echo ok
ok
$ /bin/test -d '' && echo ok || echo must_be_error
must_be_error
Both of these results match POSIX. Remember, POSIX describes different
behaviors for one argument than for two arguments (for the one-argument
case, the string "-d" is non-empty, so the result must be 0; for the
two-argument case, the string "-d" is a unary operator, and there is no
directory named '').
if [ -d $dir ]; then
The bug is in your script. You forgot to use quoting or a bashism.
Either of these fixes will correct your script (although the latter
requires bash):
if [ -d "$dir" ]; then
if [[ -d $dir ]]; then
This is not cygwin-specific.
You right!
Sorry, I miss this when read POSIX:
1 argument:
Exit true (0) if $1 is not null; otherwise, exit false.
--
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