diff --git a/src/args.rs b/src/args.rs index ca5ab0f..23d3e2e 100644 --- a/src/args.rs +++ b/src/args.rs @@ -5,7 +5,7 @@ use std::{ path::{PathBuf, MAIN_SEPARATOR}, }; -use crate::error; +use crate::{error, Shell}; use crate::config::{Config, ConfigBuilder}; pub fn get_args() -> error::Result<(Config, LevelFilter)> { @@ -119,7 +119,7 @@ where .long("shell")) // -n short form will not be removed, and instead become a shorthand for --shell=none .arg(Arg::with_name("no-shell") - .help("Do not wrap command in 'sh -c' resp. 'cmd.exe /C'") + .help("Do not wrap command in a shell. Deprecated: use --shell=none instead.") .short("n") .long("no-shell")) .arg(Arg::with_name("no-meta") @@ -227,7 +227,6 @@ where builder.clear_screen(args.is_present("clear")); builder.restart(args.is_present("restart")); builder.run_initially(!args.is_present("postpone")); - builder.no_shell(args.is_present("no-shell")); builder.no_meta(args.is_present("no-meta")); builder.no_environment(args.is_present("no-environment")); builder.no_vcs_ignore(args.is_present("no-vcs-ignore")); diff --git a/src/config.rs b/src/config.rs index 81712f9..e52a8b3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -51,9 +51,6 @@ pub struct Config { /// Specify the shell to use. #[builder(default)] pub shell: Shell, - /// Do not wrap the commands in a shell. - #[builder(default)] - pub no_shell: bool, /// Ignore metadata changes. #[builder(default)] pub no_meta: bool, @@ -98,4 +95,14 @@ impl ConfigBuilder { pub fn debug(&mut self, _: impl Into) -> &mut Self { self } + + /// Do not wrap the commands in a shell. + #[deprecated(since = "1.15.0", note = "use shell(Shell::None) instead")] + pub fn no_shell(&mut self, s: impl Into) -> &mut Self { + if s.into() { + self.shell(Shell::default()) + } else { + self.shell(Shell::None) + } + } } diff --git a/src/run.rs b/src/run.rs index d83d03d..8929968 100644 --- a/src/run.rs +++ b/src/run.rs @@ -5,7 +5,7 @@ use crate::gitignore; use crate::ignore; use crate::notification_filter::NotificationFilter; use crate::pathop::PathOp; -use crate::process::{self, Shell, Process}; +use crate::process::{self, Process}; use crate::signal::{self, Signal}; use crate::watcher::{Event, Watcher}; use std::{ @@ -168,30 +168,12 @@ impl ExecHandler { clear_screen(); } - #[cfg(windows)] - fn get_shell(config: &Config) -> Shell { - if config.no_shell { - Shell::None - } else { - Shell::Cmd - } - } - - #[cfg(not(windows))] - fn get_shell(config: &Config) -> Shell { - if config.no_shell { - Shell::None - } else { - Shell::Unix("sh".into()) - } - } - debug!("Launching child process"); let mut guard = self.child_process.write()?; *guard = Some(process::spawn( &self.args.cmd, ops, - get_shell(&self.args), + self.args.shell.clone(), !self.args.no_environment, )?);