Quit if Command Extensions are disabled
This commit is contained in:
parent
1ee0195a0d
commit
8d61617c6a
|
|
@ -219,11 +219,8 @@ zoxide can be installed in 4 easy steps:
|
||||||
> Add this to the **end** of your config file or AutoRun command:
|
> Add this to the **end** of your config file or AutoRun command:
|
||||||
>
|
>
|
||||||
> ```batchfile
|
> ```batchfile
|
||||||
> zoxide init cmd | cmd /d >nul
|
> zoxide init cmd | cmd /d /k >nul
|
||||||
> ```
|
> ```
|
||||||
>
|
|
||||||
> **Note**
|
|
||||||
> zoxide only supports `cmd.exe` with Command Extensions v2 and above.
|
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
|
||||||
16
src/shell.rs
16
src/shell.rs
|
|
@ -105,13 +105,27 @@ mod tests {
|
||||||
let source = Cmd(&opts).render().unwrap();
|
let source = Cmd(&opts).render().unwrap();
|
||||||
|
|
||||||
Command::new("cmd.exe")
|
Command::new("cmd.exe")
|
||||||
.args(["/a", "/d", "/e:on", "/q", "/v:off", "/k", "@doskey", "/macros:all"])
|
.args(["/a", "/d", "/e:on", "/q", "/v:off", "/k", "@doskey /macros:cmd.exe"])
|
||||||
.write_stdin(source)
|
.write_stdin(source)
|
||||||
.assert()
|
.assert()
|
||||||
.success()
|
.success()
|
||||||
.stderr("");
|
.stderr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[apply(opts)]
|
||||||
|
#[cfg(windows)]
|
||||||
|
fn cmd_dos(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) {
|
||||||
|
let opts = Opts { cmd, hook, echo, resolve_symlinks };
|
||||||
|
let source = Cmd(&opts).render().unwrap();
|
||||||
|
|
||||||
|
Command::new("cmd.exe")
|
||||||
|
.args(["/a", "/d", "/e:off", "/q", "/v:off", "/k", "@doskey /macros:cmd.exe"])
|
||||||
|
.write_stdin(source)
|
||||||
|
.assert()
|
||||||
|
.failure()
|
||||||
|
.stderr("zoxide: unable to init with Command Extensions disabled (see `help cmd` for details)");
|
||||||
|
}
|
||||||
|
|
||||||
#[apply(opts)]
|
#[apply(opts)]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn elvish_elvish(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) {
|
fn elvish_elvish(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,11 @@
|
||||||
{%- let section = "@rem ==========================================================================\n@rem" -%}
|
{%- let section = "@rem ==========================================================================\n@rem" -%}
|
||||||
{%- let not_configured = "@rem -- not configured --" -%}
|
{%- let not_configured = "@rem -- not configured --" -%}
|
||||||
|
|
||||||
@echo off & setlocal DisableDelayedExpansion EnableExtensions
|
@(set ^"^") >nul 2>nul && (echo off) || (
|
||||||
|
echo zoxide: unable to init with Command Extensions disabled ^(see `help cmd` for details^)
|
||||||
|
) >&2 && exit /b 1 "Command Extensions are disabled" 2>nul
|
||||||
|
|
||||||
|
setlocal DisableDelayedExpansion EnableExtensions
|
||||||
|
|
||||||
if /i "%~f0"=="%~dpnx0" (
|
if /i "%~f0"=="%~dpnx0" (
|
||||||
set ^"$p=%%<nul"
|
set ^"$p=%%<nul"
|
||||||
|
|
@ -156,6 +160,4 @@ endlocal & set OLDPWD=
|
||||||
{{ section }}
|
{{ section }}
|
||||||
@rem To initialize zoxide, add this to your configuration or AutoRun command:
|
@rem To initialize zoxide, add this to your configuration or AutoRun command:
|
||||||
@rem
|
@rem
|
||||||
@rem zoxide init cmd | cmd /d >nul
|
@rem zoxide init cmd | cmd /d /k >nul
|
||||||
@rem
|
|
||||||
@rem Note: zoxide only supports `cmd.exe` with Command Extensions v2 and above.
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue