GNU bug report logs - #8749
mkdir: feature request --reference

Previous Next

Package: coreutils;

Reported by: Shaun Jackman <sjackman <at> bcgsc.ca>

Date: Fri, 27 May 2011 23:32:03 UTC

Severity: wishlist

Full log


Message #8 received at 8749 <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: Shaun Jackman <sjackman <at> bcgsc.ca>
Cc: 8749 <at> debbugs.gnu.org
Subject: Re: bug#8749: mkdir: feature request --reference
Date: Sat, 28 May 2011 19:46:52 -0600
Shaun Jackman wrote:
> My primary use case for this feature is to create a shell alias:
> 	alias mkdir='mkdir --reference=.'
> so that in interactive shells, new directories are created with the same
> permissions as their parent directory.

If your primary purpose is for an alias then you can do it this way:

  alias mkdirchmod='mkdir -m $(stat -c %a .)'

  alias mkdirchmod='install -d -m $(stat -c %a .)'

However a shell function might serve you better:

  mkdirchmod() { mkdir "$@" ; chmod --reference=. "$@" ;}

But I think this task is better served by not doing it all and instead
using the technique of User Private Groups.

> My goal is to have directories in my personal home directory to have
> permission 755 and directories in my shared work space to have
> permission 775, so that other members of my group may create new files
> in shared directories. Files should have permission 755 so that members
> of my group cannot modify files that I've created.

The UPG (User Private Group) technique works very well in this
situation.  There is a lot of documentation available on UPG on the
net and so I won't include a specific pointer.  Search for it and you
will find a lot of information on it.  And different operating systems
deal with configuring it differently and so you would want to look at
documentation for your particular system.  But I highly recommend
using the technique.

I generally dislike combining the functionality of several different
commands into one command.  In this case combining mkdir and chmod and
I don't see any reason they can't be used individually.  Plus mkdir
already allows you to create directories with a specified permission
and this is feature creep into the area of the 'install' command which
also already allows creating directories of specified permissions.

Bob




This bug report was last modified 14 years and 79 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.