Tweaks to help (#700)

This commit is contained in:
Félix Saparelli 2023-11-28 01:57:01 +13:00 committed by GitHub
parent 9af9189ac4
commit 0e94f220e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 27 deletions

View File

@ -412,8 +412,7 @@ pub struct Args {
/// If the value has spaces, it is parsed as a command line, and the first word used as the
/// shell program, with the rest as arguments to the shell.
///
/// The command is run with the '-c' flag (except for 'cmd' and 'powershell' on Windows, where
/// the '/C' option is used).
/// The command is run with the '-c' flag (except for 'cmd' on Windows, where it's '/C').
///
/// Note that the default shell will change at the next major release: the value of '$SHELL'
/// will be respected, falling back to 'sh' on unix and to PowerShell on Windows.
@ -424,8 +423,8 @@ pub struct Args {
/// and may not work as expected in all cases.
///
/// Using 'none' is a little more efficient and can enable a stricter interpretation of the
/// input, but it also means that you can't use shell features like globbing, redirection, or
/// pipes.
/// input, but it also means that you can't use shell features like globbing, redirection,
/// control flow, logic, or pipes.
///
/// Examples:
///
@ -433,11 +432,11 @@ pub struct Args {
///
/// $ watchexec -n -- zsh -x -o shwordsplit scr
///
/// Use with powershell:
/// Use with powershell core:
///
/// $ watchexec --shell=powershell -- test-connection localhost
/// $ watchexec --shell=pwsh -- Test-Connection localhost
///
/// Use with cmd:
/// Use with cmd (default on Windows):
///
/// $ watchexec --shell=cmd -- dir
///
@ -583,6 +582,7 @@ pub struct Args {
/// environment variable.
///
/// Finally, the special 'none' mode will disable event emission entirely.
// TODO: when deprecating, make the none mode the default.
#[arg(
long,
help_heading = OPTSET_COMMAND,

View File

@ -385,9 +385,6 @@ fn interpret_command_args(args: &Args) -> Result<Arc<Command>> {
#[cfg(not(windows))]
Some("default") => Some(Shell::new("sh")),
#[cfg(windows)]
Some("powershell") => Some(Shell::new(available_powershell())),
Some(other) => {
let sh = other.split_ascii_whitespace().collect::<Vec<_>>();
@ -425,12 +422,6 @@ fn interpret_command_args(args: &Args) -> Result<Arc<Command>> {
}))
}
#[cfg(windows)]
fn available_powershell() -> String {
// TODO
todo!("figure out if powershell.exe is available, and use that, otherwise use pwsh.exe")
}
fn setup_process(job: Job, command: Arc<Command>, outflags: OutputFlags) {
if outflags.toast {
Notification::new()

View File

@ -209,13 +209,13 @@ By default, Watchexec will use \*(Aqsh\*(Aq on unix and \*(Aqcmd\*(Aq (CMD.EXE)
If the value has spaces, it is parsed as a command line, and the first word used as the shell program, with the rest as arguments to the shell.
The command is run with the \*(Aq\-c\*(Aq flag (except for \*(Aqcmd\*(Aq and \*(Aqpowershell\*(Aq on Windows, where the \*(Aq/C\*(Aq option is used).
The command is run with the \*(Aq\-c\*(Aq flag (except for \*(Aqcmd\*(Aq on Windows, where it\*(Aqs \*(Aq/C\*(Aq).
Note that the default shell will change at the next major release: the value of \*(Aq$SHELL\*(Aq will be respected, falling back to \*(Aqsh\*(Aq on unix and to PowerShell on Windows.
The special value \*(Aqnone\*(Aq can be used to disable shell use entirely. In that case, the command provided to Watchexec will be parsed, with the first word being the executable and the rest being the arguments, and executed directly. Note that this parsing is rudimentary, and may not work as expected in all cases.
Using \*(Aqnone\*(Aq is a little more efficient and can enable a stricter interpretation of the input, but it also means that you can\*(Aqt use shell features like globbing, redirection, or pipes.
Using \*(Aqnone\*(Aq is a little more efficient and can enable a stricter interpretation of the input, but it also means that you can\*(Aqt use shell features like globbing, redirection, control flow, logic, or pipes.
Examples:
@ -223,11 +223,11 @@ Use without shell:
$ watchexec \-n \-\- zsh \-x \-o shwordsplit scr
Use with powershell:
Use with powershell core:
$ watchexec \-\-shell=powershell \-\- test\-connection localhost
$ watchexec \-\-shell=pwsh \-\- Test\-Connection localhost
Use with cmd:
Use with cmd (default on Windows):
$ watchexec \-\-shell=cmd \-\- dir

View File

@ -332,8 +332,8 @@ functions.
If the value has spaces, it is parsed as a command line, and the first
word used as the shell program, with the rest as arguments to the shell.
The command is run with the -c flag (except for cmd and powershell on
Windows, where the /C option is used).
The command is run with the -c flag (except for cmd on Windows, where
its /C).
Note that the default shell will change at the next major release: the
value of \$SHELL will be respected, falling back to sh on unix and to
@ -347,7 +347,7 @@ work as expected in all cases.
Using none is a little more efficient and can enable a stricter
interpretation of the input, but it also means that you cant use shell
features like globbing, redirection, or pipes.
features like globbing, redirection, control flow, logic, or pipes.
Examples:
@ -355,11 +355,11 @@ Use without shell:
\$ watchexec -n \-- zsh -x -o shwordsplit scr
Use with powershell:
Use with powershell core:
\$ watchexec \--shell=powershell \-- test-connection localhost
\$ watchexec \--shell=pwsh \-- Test-Connection localhost
Use with cmd:
Use with cmd (default on Windows):
\$ watchexec \--shell=cmd \-- dir

Binary file not shown.