This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

'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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]