GNU bug report logs -
#45258
mkdir man page unclear in describing -m flag
Previous Next
Reported by: Chris Colohan <chris <at> colohan.com>
Date: Tue, 15 Dec 2020 17:52:01 UTC
Severity: normal
Merged with 34009
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 16/12/2020 08:28, Bernhard Voelker wrote:
> On 12/15/20 9:00 PM, Paul Eggert wrote:
>> Thanks for your bug report. I installed the attached patch; although it
>> doesn't use the exact wording you proposed, I hope it works well enough.
>
> Thanks for clarifying.
>
>> +If the @option{-m} option is also given, it does not affect
>> +file permission bits of any newly-created parent directories.
>> +To control these bits, set the
>> umask before invoking @command{mkdir}. [...]
>
> Some further thoughts on this - maybe just for my reference:
>
> One aspect of using -p is that the user doesn't want to get an error if
> the target or any of its parent directories already exists.
>
> If changing the umask before invoking mkdir is not that easy - maybe
> because not called via a shell -, then an alternative to the above
> umask method is to reference each of the target directories separately,
> e.g.:
> $ mkdir -pm 0700 dir1 dir1/dir2 dir1/dir2/dir3
>
> But it is important to know that 'mkdir' does not adjust the permission
> bits of any of those already existing directories.
>
> Therefore, if one does not want to get a failure for already existing
> intermediate directories, and still wants their permission bits to get
> adjusted, then one can use 'install' instead of 'mkdir' (still passing
> each directory level as separate argument!):
>
> $ install -dm 0700 dir1 dir1/dir2 dir1/dir2/dir3
Insightful comments. I've updated the gotchas note with them:
https://www.pixelbeat.org/docs/coreutils-gotchas.html#mkdir
cheers,
Pádraig
This bug report was last modified 2 years and 246 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.