GNU bug report logs - #8736
chmod -p --parents

Previous Next

Package: coreutils;

Reported by: francky.leyn <at> telenet.be

Date: Thu, 26 May 2011 22:31:02 UTC

Severity: normal

Tags: wontfix

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jim Meyering <jim <at> meyering.net>
To: Jérémy Compostella <jeremy.compostella <at> gmail.com>
Cc: Erik Auerswald <auerswal <at> unix-ag.uni-kl.de>, 8736 <at> debbugs.gnu.org, coreutils <at> gnu.org, francky.leyn <at> telenet.be
Subject: bug#8736: chmod -p --parents
Date: Thu, 23 Feb 2012 12:04:22 +0100
Jérémy Compostella wrote:
>> On Thu, May 26, 2011 at 10:13:05PM +0200, francky.leyn <at> telenet.be wrote:
>> >
>> > In the past, I was an advocate of the -p --parents option for
>> > mkdir. By now this is realised. Now I'm doing the same for chmod.
>> > [...]
>> > I want to be able to execute the following:
>> >
>> > chmod a+rx -p ~/dir1/dir2/dir3/file.ext
>>
>> I like the proposal.
>> > It should be more refined however: the dirs
>> > should be rx, but the file only r.
>>
>> You can use a capital X to automatically handle the directory case. But
>> please take a look at the docs for the _exact_ meaning of X.
> I made a first implementation of this chmod --parents feature (see the
> attached patch). I do not support the second part since 'X' is already
> in used for the "Conditional Executability" feature. I have no idea how
> to support it.
>
> I don't have written the documentation for now. I would like to have
> your opinion about this patch first as I maybe missed some corner case
> or the code should be written another way or even something else ...
>
> I really hope you will find time to look at it.

Hi Jérémy,

Thank you for the patch, but as usual with option-adding patches,
we have to justify it, i.e., to ask "why not do it some other way?"
Or, "is this too specialized to merit an option?"

Here's a little bash/zsh script that does it:

chmod-parents()
{
  local p=$2
  while :; do
    chmod "$1" "$p" || break
    test "$p" = . && break
    p=$(dirname "$p")
  done
}

And an example showing how to use it:

  p=d1/d2/d3
  mkdir -p $p
  touch $p/file
  chmod-parents 505 $p/file




This bug report was last modified 6 years and 219 days ago.

Previous Next


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