mirror of
https://github.com/nushell/nushell
synced 2024-11-10 07:04:13 +00:00
mkdir
umask fix (#12354)
# Description
Fixes how the directory permissions are calculated in `mkdir`. Instead
of subtraction, the umask is actually used as a mask via negation
followed by bitwise and with the default mode. This matches how [uucore
calculates](cac7155fba/src/uu/mkdir/src/mkdir.rs (L61)
)
the mode.
This commit is contained in:
parent
3bc0b332f4
commit
aaefc5e110
2 changed files with 2 additions and 2 deletions
|
@ -13,7 +13,7 @@ const DEFAULT_MODE: u32 = 0o777;
|
|||
|
||||
#[cfg(not(windows))]
|
||||
fn get_mode() -> u32 {
|
||||
DEFAULT_MODE - mode::get_umask()
|
||||
!mode::get_umask() & DEFAULT_MODE
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
|
|
|
@ -141,7 +141,7 @@ fn mkdir_umask_permission() {
|
|||
assert_eq!(
|
||||
actual, 0o40755,
|
||||
"Most *nix systems have 0o00022 as the umask. \
|
||||
So directory permission should be 0o40755 = 0o40777 - 0o00022"
|
||||
So directory permission should be 0o40755 = 0o40777 & (!0o00022)"
|
||||
);
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue