BSD vs SysV -- [ -w <dir> ] different?

Martin Weitzel martin at mwtech.UUCP
Thu Dec 14 07:54:19 AEST 1989


In article <4640 at itivax.iti.org> scs at itivax.iti.org (Steve Simmons) writes:
>I've run into what appears to be an incompatibility between SysV and
>BSD (and Ultrix), and wanted to get some feedback:
>
>Given a directory foo, with permissions 777 and owned by root, running
>as root the following bourne shell script gives different results:
>
>#!/bin/sh
>if [ -w foo ] ; then
[rest deleted]

Obviously, there are too ways to define "writable":
1) Will I be able to open the file for writing?
2) Will I have the possibility to *change* the contents?

Because of the special nature of directories in UNIX, these two
questions must be answered differently (even to the Super-User):

1) You are *not* allowed to open a directory-file for writing, but
2) you *may* be able to change its contents with system services
   like "creat" (create new file) "link" and "unlink".

Now, SysV takes the one interpretation, BSD the other. As much as
I know, this problem occured allready in XENIX, when they shifted
from the external 'test'-command to the internal '[...]'-feature
of the shell (in System III). Some command scripts, that were
blindly converted (to achieve better performance) just went
the wrong way then.

IMHO, many many unix consultants (as me) would have no work, if
such inconsistencies were ommitted from the systems ... :-)
-- 
<<< MW -- email: see header -- voice: 49-(0)6151-6 56 83 >>>



More information about the Comp.unix.questions mailing list