[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suggestion for chmod version 4.1

From: Bob Proulx
Subject: Re: Suggestion for chmod version 4.1
Date: Thu, 14 Jun 2001 23:04:57 -0600

> I would like to have a command to set the setgid bit on all the
> directories under a given directory.
> I modified the sources to do that.  I add a option S (like X) that
> set the setgid bit only on a directory.  I don't know if it could be
> useful for someone else, but I give you the sources.

First, thanks for your submission.  Also the inclusion of patches is
most rare and very nice to see.  However, I disagree that this
functionality should exist in chmod.

While it is possible and certainly your supplied patch proves it this
is not in the philosophy of UNIX as a modular set of commands.  The
functionality you wish to use already exists in the 'find' command.
There is no need to add it to every other command in the operating
system as well.  That would cause much code bloat.  It would also
complicate many commands and lead to more bugs due to the added
complexity.  Most commands would implement it differently.  Adding
this functionality to chmod would imply adding it to other unix
commands like chown, chgrp, touch, etc.

[My editorial remarks are that some other systems do little themselves
and mostly just launch commands.  In those systems every command
becomes a complete environment.  In those environments programs like
xtree become necessary but are rarely needed on UNIX.]

Fortunately this functionality already exists in UNIX in the find
command.  It implements file finding and directory traversal
operations and is very useful with most of the core UNIX commands such
as those in fileutils.

Try using the following as the more normal UNIX method of doing what
you want.  This type of design allows UNIX to build functionality in a
modular way and to use it across all commands.

  find . -type d -print | xargs chmod g+s

This runs chmod only on directories below the current directory and
sets the setgid bit.  This works on all traditional UNIX systems.

You will find a corner case where filenames containing newlines do not
work since newlines are used to delimit filenames for the xargs
command.  The GNU versions of these commands extend the functionality
to work with filenames that contain newlines as well.  Using the more
modern extension -print0 and -0 functionality the filenames are zero
character delimited and therefore work with all valid UNIX filesystem
filenames.  This works only with the GNU and other modern versions
which include this functionality.  But it is more robust than the
classic method and I recommend it when strict intersystem portability
is not required.

  find . -type d -print0 | xargs -0 chmod g+s

Bob Proulx

reply via email to

[Prev in Thread] Current Thread [Next in Thread]