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
[Message part 1 (text/plain, inline)]
I like to present a challenge to my software engineer friends: can you
tell me what this command does on Linux, if run in an empty directory?
mkdir -m 0755 -p ./usr/bin/foo
If they read the mkdir man page (
https://man7.org/linux/man-pages/man1/mkdir.1.html), they almost always say
the answer is:
- create the directory ./usr, with the mode 0755
- create the directory ./usr/bin, with the mode 0755
- create the directory ./usr/bin/foo, with the mode 0755
They are wrong. (Side note -- this misunderstanding contributed to one of
the scariest outages Google has ever seen,
https://www.pdl.cmu.edu/SDI/2012/083012b.html).
What it actually does:
- create the directory ./usr, with the mode based on the umask
- create the directory ./usr/bin, with the mode based on the umask
- create the directory ./usr/bin/foo, with the mode 0755
I tried at the time to get the man page corrected, but I was told at the
time that nobody reads man pages, and the info page is correct, so it won't
be fixed.
I figured after almost 10 years, perhaps thinking has evolved. Can we fix
the man page?
I have a suggested fix: the current man page reads:
-p, --parents
no error if existing, make parent directories as needed
I can be updated to read:
-p, --parents
no error if existing, make parent directories as needed,
setting
their file permission bits to the umask modified by ‘u+wx’.
I copied the new text from the info page.
Thanks!
Chris
[Message part 2 (text/html, inline)]
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.