[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#45258: mkdir man page unclear in describing -m flag
From: |
Bernhard Voelker |
Subject: |
bug#45258: mkdir man page unclear in describing -m flag |
Date: |
Wed, 16 Dec 2020 09:28:52 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 |
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
Have a nice day,
Berny