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.