bug-coreutils
[Top][All Lists]
Advanced

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

bug#8749: mkdir: feature request --reference


From: Shaun Jackman
Subject: bug#8749: mkdir: feature request --reference
Date: Mon, 30 May 2011 10:29:10 -0700

Hi Bob,

I was using exactly that shell function that you described, but it
doesn't work for
        mkdir -p foo/bar

I'm using the alias you gave, which works better. Thanks.

I've noticed one issue, which I feel is a bug in mkdir. When using mkdir
-pm, the specified mode is applied only to the final directory and not
the parent directories:

$ mkdir -pm 775 foo/bar
$ ls -ld foo foo/bar
drwxr-xr-x 3 sjackman assembly 4096 May 30 10:27 foo
drwxrwxr-x 2 sjackman assembly 4096 May 30 10:27 foo/bar

I would expect both foo and foo/bar to have mode 775.

Cheers,
Shaun

On Sat, 2011-05-28 at 18:46 -0700, Bob Proulx wrote:
> 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






reply via email to

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