Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!amdcad!sun!pitstop!sundc!seismo!uunet!mcvax!epg From: epg@cwi.nl (Ed Gronke) Newsgroups: comp.unix.wizards Subject: test(1) and inconsistencies Keywords: test, files and directories, writeability Message-ID: <411@sering.cwi.nl> Date: 8 Feb 88 16:17:35 GMT Organization: CWI, Amsterdam Lines: 35 A query for people out there about test(1) and the interpretation of a particular phrase on the manual page, specifically, "-w file true if the file exists and is writeable" (4.3 BSD) "-w file true if file exists and is writable" (Sun OS 3.2) Now, these same options do two different things on Sun's running Sun OS and on Vaxes (and CCI's) running 4.3 when applied to a writeable directory (like /tmp) Try the following -- (shell script) if /bin/test -w /tmp then echo write permission on /tmp else echo no write permission on /tmp fi On Sun's, this returns the message "write permission on /tmp" and on 4.3 it returns "no write permission on /tmp". Now, on 4.3, the reason it does it is because the test for "writeability" (sp?) is to attempt to open the file for writing (which of course fails for a directory). I don't have the Sun source to check how they do it. But, which is right (or write -:))? (I think Sun is right because of the following question? ) And, if 4.3 is right, how do you test for write permission on a directory in the shell? -- Ed Gronke (epg@mcvax.cwi.nl) (Centrum voor Wiskunde en Informatica)