diff --git a/crates/nu-command/src/filesystem/umkdir.rs b/crates/nu-command/src/filesystem/umkdir.rs index 6fdda51ead..949e6ba794 100644 --- a/crates/nu-command/src/filesystem/umkdir.rs +++ b/crates/nu-command/src/filesystem/umkdir.rs @@ -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)] diff --git a/crates/nu-command/tests/commands/umkdir.rs b/crates/nu-command/tests/commands/umkdir.rs index 5aa4b0f40b..ebb2b932ab 100644 --- a/crates/nu-command/tests/commands/umkdir.rs +++ b/crates/nu-command/tests/commands/umkdir.rs @@ -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)" ); }) }