mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-28 22:21:33 +02:00
Change the default of Shell
This commit is contained in:
parent
2c894266a8
commit
6e414d1de4
@ -3,27 +3,27 @@ use tracing::trace;
|
|||||||
|
|
||||||
/// Shell to use to run commands.
|
/// Shell to use to run commands.
|
||||||
///
|
///
|
||||||
/// `Cmd` and `Powershell` are special-cased because they have different calling
|
/// `Cmd` and `Powershell` are special-cased because they have different calling conventions. Also
|
||||||
/// conventions. Also `Cmd` is only available in Windows, while `Powershell` is
|
/// `Cmd` is only available in Windows, while `Powershell` is also available on unices (provided the
|
||||||
/// also available on unices (provided the end-user has it installed, of course).
|
/// end-user has it installed, of course).
|
||||||
///
|
///
|
||||||
/// See [`Config.cmd`] for the semantics of `None` vs the
|
/// See [`Config.cmd`] for the semantics of `None` vs the other options.
|
||||||
/// other options.
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum Shell {
|
pub enum Shell {
|
||||||
/// Use no shell, and execute the command directly.
|
/// Use no shell, and execute the command directly.
|
||||||
|
///
|
||||||
|
/// This is the default, however as consumer of this library you are encouraged to set your own
|
||||||
|
/// default as makes sense in your application / for your platform.
|
||||||
None,
|
None,
|
||||||
|
|
||||||
/// Use the given string as a unix shell invocation.
|
/// Use the given string as a unix shell invocation.
|
||||||
///
|
///
|
||||||
/// This means two things:
|
/// This means two things:
|
||||||
/// - the program is invoked with `-c` followed by the command, and
|
/// - the program is invoked with `-c` followed by the command, and
|
||||||
/// - the string will be split on space, and the resulting vec used as
|
/// - the string will be split on space, and the resulting vec used as execvp(3) arguments:
|
||||||
/// execvp(3) arguments: first is the shell program, rest are additional
|
/// first is the shell program, rest are additional arguments (which come before the `-c`
|
||||||
/// arguments (which come before the `-c` mentioned above). This is a very
|
/// mentioned above). This is a very simplistic approach deliberately: it will not support
|
||||||
/// simplistic approach deliberately: it will not support quoted
|
/// quoted arguments, for example. Use [`Shell::None`] with a custom command vec for that.
|
||||||
/// arguments, for example. Use [`Shell::None`] with a custom command vec
|
|
||||||
/// if you want that.
|
|
||||||
Unix(String),
|
Unix(String),
|
||||||
|
|
||||||
/// Use the Windows CMD.EXE shell.
|
/// Use the Windows CMD.EXE shell.
|
||||||
@ -36,20 +36,14 @@ pub enum Shell {
|
|||||||
///
|
///
|
||||||
/// This is invoked with `-Command` followed by the command.
|
/// This is invoked with `-Command` followed by the command.
|
||||||
///
|
///
|
||||||
/// This is preferred over `Unix("pwsh")`, though that will also work
|
/// This is preferred over `Unix("pwsh")`, though that will also work on unices due to
|
||||||
/// on unices due to Powershell supporting the `-c` short option.
|
/// Powershell supporting the `-c` short option.
|
||||||
Powershell,
|
Powershell,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Shell {
|
impl Default for Shell {
|
||||||
#[cfg(windows)]
|
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::Powershell
|
Self::None
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::Unix("sh".into())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user