Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ll-xn!husc6!cmcl2!brl-adm!adm!franco@MIKEY.BBN.COM From: franco@MIKEY.BBN.COM Newsgroups: comp.unix.wizards Subject: /bin/test and stat(2) Message-ID: <9479@brl-adm.ARPA> Date: Thu, 24-Sep-87 16:49:57 EDT Article-I.D.: brl-adm.9479 Posted: Thu Sep 24 16:49:57 1987 Date-Received: Sat, 26-Sep-87 13:27:53 EDT Sender: news@brl-adm.ARPA Lines: 35 I understand that the 'stat' system call on a NULL string for a file name will default to '.' (DOT), the current directory. You don't have to explain to me why this is. I already know why. I only just recently discovered this fact. But what I would like to know is, why does the test -d of a NULL string in the following sample script return true? Foo="" if test -d "$Foo" then do something constructive fi don't do anything Let me rephrase the question. I understand that /bin/test just does a 'stat' call on the NULL filename string which defaults to DOT which does exist and is a directory and that is why test returned true and the 'do something constructive' part would get executed. But why should I have to know in advance that NULL will default to DOT in the case when I'm testing for the existence of a directory? Shouldn't /bin/test handle a NULL string in a special way, i.e..return false? I don't see why I have to know in advance that NULL defaults to DOT and I shouldn't have to do two tests to find out if the file is a directory. Also, the documentation doesn't say anything about the case of a NULL filename when using 'test -d'. To me, this really sounds like a bug or a mis-implementation and documentation of /bin/test. Please forward these questions to people who you think should read it just in case unix-wizards doesn't cover the appropriate group, i.e..other mailing lists. And please CC me on all responses to this message, for sometimes I don't read all of the unix-wizards digests. thank you, -franco CSNET: franco%bbn.com@relay.cs.net UUCP: ..!harvard!franco@bbn.com