home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!mcsun!sunic!psinntp!psinntp!sadtler!rick
- From: rick@sadtler.sadtler.com (Rick Morris)
- Subject: Nothing is a directory?
- Message-ID: <1992Sep3.231718.16061@sadtler.com>
- Sender: rick@sadtler.com (Rick Morris)
- Organization: Sadtler Research Laboratories
- Date: Thu, 3 Sep 1992 23:17:18 GMT
- Lines: 39
-
- I came across an interesting situation I thought I'd throw
- out for discussion.
-
- In a Bourne script, I ask the user for the name of a
- directory. If the user enters return, the variable
- contains nothing. Then I test the results.
-
- #!/bin/sh
- #
- read dir
- if test -d "$dir"; then
- echo "Yes, a directory."
- else
- echo "No, not a directory."
- fi
- #
- exit 0
- #
-
- Well guess what. On our SUN (4.1.3), nothing is
- a directory. That little script results in:
-
- Yes, a directory.
-
- On our SGI, nothing is not a directory. That
- little script results in:
-
- No, not a directory.
-
- So, who is right? Is nothing a directory?
- I read in the man page that -d returns true if argument
- exists and is a directory, so I would assume that the
- null argument should be false like the SGI.
-
- -Rick.
- --
- Rick Morris Email: rick@sadtler.com
- Sadtler Research Labs, Philadelphia -But I speak for myself
- ---------------------------------------------------------------
-