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. -- Eric Blake ebl...@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org -- 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