Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site mcvax.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!jaap From: jaap@mcvax.UUCP (Jaap Akkerhuis) Newsgroups: net.unix-wizards Subject: Semantics of test Message-ID: <874@mcvax.UUCP> Date: Thu, 7-Nov-85 19:46:52 EST Article-I.D.: mcvax.874 Posted: Thu Nov 7 19:46:52 1985 Date-Received: Sat, 9-Nov-85 05:44:35 EST Reply-To: jaap@mcvax.UUCP (Jaap Akkerhuis) Organization: CWI, Amsterdam Lines: 39 In all the unix systems I know about there was the program test, to be used inside shell programs. test -w foo will return the exit status 0 when foo is writable. However, if foo is a directory, and although I have permission to write in the directory, it will have the exit status 1. Odd as it seems at first hand, it can be interpret as correct. Even if you own the directory, you cannot copy an arbitrary file "on top of it". (Your file system would be seriously be corrupted). Let us call this the purist view. Another interpretation is that if you can create a file in the directory, the directory can be considered writable. Let us call this the sloppy view. Shells with a build in "test" command, like the sysV and the ksh take the sloppy view. These different interpretations of test -w give a problem in porting shell programs. Question: What to do. Change "test", so it will be sloppy or should the shells with build in "test" be reformed to take the purist view. Jaap Akkerhuis (mcvax!jaap) PS. Of course, if I have a shell file which would take care of the interpretation differences, I would use /bin/test in all cases. But since AT&T in their infinite wishdom removed /bin/test, this is going to be a pain: if test -f /bin/test then TEST=/bin/test #purist test found else TEST=test #sloppy test found fi The rest is left as an exercise to the reader.