The nsh mkdir command is based upon zsh, not bash. Is that the specified behavior for mkdir in zsh 4.2.4?
My interpretation of the ZSH documentation is that it should explicitly set the permission based on the -m option and not apply the umask.
"mkdir [ -p ] [ -m mode ] dir ... Creates directories. With the -p option, non-existing parent directories are first created if necessary, and there will be no complaint if the directory already exists. The -m option can be used to specify (in octal) a set of file permissions for the created directories, otherwise mode 777 modified by the current umask (see man page umask(2)) is used. "
Might be a bug. File a support ticket
I’m seeing some inconsistent results:
mkdir -m 0700 foo6
drwx------ 2 oozy oozy 4096 Mar 16 15:59 foo6
mkdir -m 0770 foo7 && ls -la | grep foo7
drwxrwx--- 2 oozy oozy 4096 Mar 16 16:00 foo7
mkdir -m 0777 foo8 && ls -la | grep foo8
drwxrwxr-x 2 oozy oozy 4096 Mar 16 16:00 foo8
mkdir -m 0007 foo12 && ls -la | grep foo12
d------r-x 2 oozy oozy 4096 Mar 16 16:02 foo12
mkdir -m 0077 foo13 && ls -la | grep foo13
d---rwxr-x 2 oozy oozy 4096 Mar 16 16:03 foo13
mkdir -m 0500 foo9 && ls -la | grep foo9
dr-x------ 2 oozy oozy 4096 Mar 16 16:01 foo9
mkdir -m 0550 foo10 && ls -la | grep foo10
dr-xr-x--- 2 oozy oozy 4096 Mar 16 16:02 foo10
mkdir -m 0555 foo11 && ls -la | grep foo11
dr-xr-xr-x 2 oozy oozy 4096 Mar 16 16:02 foo11
mkdir -m 0002 foo15 && ls -la | grep foo15
d--------- 2 oozy oozy 4096 Mar 16 16:05 foo15
it seems like it’s having problems w/ the everyone write bit.
actually i take that back:
-m mode Set the file permissions of all created directories to mode,
where mode is an octal value. By default the mode of the newly
created directories is calculated to be:
0777 minus <current umask of local host>
i take that to mean if my umask is 0002 and i run mkdir -m 0777 foo then foo will be 0775
The way I interpret that documentation is - the mkdir without the -m option will use 0777 minus the umask as the default permissions of the file, otherwise you could use the -m option to explicit set the permissions.
The wording of the man page is a bit unclear and confusing. However, if you look at the documentation on from zsh regarding the -m option, it leads you to believe the permissions can be explicitly set. Also it operates in this manner in when using a bash shell.
i was going to post last night – I think you are right – I re-read that, and the linux mkdir man page and the –m should override the umask. It appears the nsh one is not. our manpage is confusing though – it should say something like “the default behavior of mkdir is to subtract the umask, w/ the –m option the default umask will be overridden”