shell: why [ -d ] returns true instead of false? -
as told here, command [ -d file ] used check whether file directory.
however, when miss file parameter in expression, still returns true.
why? how shell interpret expression then?
example should straightforward enough :)
$ [ -d /tmp ] $ echo $? # prints 0 $ [ -d ] $ echo $? # why prints 0 well?
it gets interpreted [ -n -d ]. in other words, since you've provided 1 argument -d gets treated if other string, , can read in the man page:
-n string
length ofstringnonzero
string
equivalent-n string
Comments
Post a Comment