Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!cmcl2!brl-adm!adm!franco@MIKEY.BBN.COM From: franco@MIKEY.BBN.COM Newsgroups: comp.unix.wizards Subject: Re: /bin/test and stat(2) Message-ID: <9501@brl-adm.ARPA> Date: Sun, 27-Sep-87 17:15:47 EDT Article-I.D.: brl-adm.9501 Posted: Sun Sep 27 17:15:47 1987 Date-Received: Sun, 27-Sep-87 23:41:42 EDT Sender: news@brl-adm.ARPA Lines: 25 Amos: If "$foo" is a NULL string /bin/test doesn't replace foo with a '.'. if [ -d "$foo" ]; then do_something $foo/xx fi With the above script if foo is null then the do something will act on /xx instead of ./xx, clearly two different directories and something that a programmer might not want to happen. You see, my point to the original questions was, Why do I have to know in advance that test -d "" is going to say that "" is a directory when it is clearly not a directory. And, why should I have to do two tests to find out if "$foo" is a directory, /bin/test should do it. Relying on the default sounds to me to be bad programming practice, but I've looked into source code such as ls.c and it does the same thing, rely on the default, namely if you do 'ls ""' it does an 'ls .'. Other programs do the same, chmod chown, cd and the like. All of which I consider poorly written if they rely on the default like that. Point 2 is, what if the do_something was cd $foo; rm -rf $foo and the script ran as root? OH MY GOD!!!!!!!!! -franco