diff --git a/src/builtins/cd.rs b/src/builtins/cd.rs index 040338813..71f0f69ed 100644 --- a/src/builtins/cd.rs +++ b/src/builtins/cd.rs @@ -9,7 +9,6 @@ use crate::{ }; use errno::Errno; use libc::{fchdir, EACCES, ELOOP, ENOENT, ENOTDIR, EPERM}; -use nix::sys::stat::Mode; use std::{os::fd::AsRawFd, sync::Arc}; // The cd builtin. Changes the current directory to the one specified or to $HOME if none is @@ -87,7 +86,7 @@ pub fn cd(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Optio errno::set_errno(Errno(0)); - let res = wopen_dir(&norm_dir, Mode::empty()).map_err(|err| err as i32); + let res = wopen_dir(&norm_dir).map_err(|err| err as i32); let res = res.and_then(|fd| { if unsafe { fchdir(fd.as_raw_fd()) } == 0 { diff --git a/src/fds.rs b/src/fds.rs index 03ebad36f..6ea5c6d10 100644 --- a/src/fds.rs +++ b/src/fds.rs @@ -261,13 +261,13 @@ pub fn open_cloexec(path: &CStr, flags: OFlag, mode: nix::sys::stat::Mode) -> ni /// Wide character version of open_dir() that also sets the close-on-exec flag (atomically when /// possible). -pub fn wopen_dir(pathname: &wstr, mode: nix::sys::stat::Mode) -> nix::Result { - open_dir(wcs2zstring(pathname).as_c_str(), mode) +pub fn wopen_dir(pathname: &wstr) -> nix::Result { + open_dir(wcs2zstring(pathname).as_c_str()) } /// Narrow version of wopen_dir(). -pub fn open_dir(path: &CStr, mode: nix::sys::stat::Mode) -> nix::Result { - open_cloexec(path, OFlag::O_RDONLY | OFlag::O_DIRECTORY, mode).map(OwnedFd::from) +pub fn open_dir(path: &CStr) -> nix::Result { + open_cloexec(path, OFlag::O_RDONLY | OFlag::O_DIRECTORY, nix::sys::stat::Mode::empty()).map(OwnedFd::from) } /// Close a file descriptor `fd`, retrying on EINTR. diff --git a/src/parser.rs b/src/parser.rs index 2478146b9..99ed6ee8c 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -352,7 +352,7 @@ impl Parser { global_event_blocks: AtomicU64::new(0), }); - match open_dir(CStr::from_bytes_with_nul(b".\0").unwrap(), Mode::empty()) { + match open_dir(CStr::from_bytes_with_nul(b".\0").unwrap()) { Ok(fd) => { result.libdata_mut().cwd_fd = Some(Arc::new(fd)); }