mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 09:53:43 +01: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
@ -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 New Issue
Block a user