Skip to content

Commit 7bc5e2b

Browse files
committed
Fix stdin end of input
1 parent 3793b8f commit 7bc5e2b

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ indent_style = space
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.(md,rst,txt}]
11+
[*.{md,rst,txt}]
1212
indent_size = unset
1313
trim_trailing_whitespace = false
1414

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ zoxide can be installed in 4 easy steps:
220220
> Add this to the **end** of your config file or AutoRun command:
221221
>
222222
> ```batchfile
223-
> zoxide init cmd --hook none | cmd /d/q/k >nul
223+
> zoxide init cmd | cmd /d/q/k echo off
224224
> ```
225225
226226
</details>

man/man1/zoxide-init.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Add this to the \fBend\fR of your config file (usually \fB~/.bashrc\fR):
1717
Add this to the \fBend\fR of your config file or AutoRun command:
1818
.sp
1919
.nf
20-
\fBzoxide init cmd --hook none | cmd /d/q/k >nul\fR
20+
\fBzoxide init cmd | cmd /d/q/k echo off\fR
2121
.fi
2222
.TP
2323
.B elvish

src/shell.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ mod tests {
104104
let source = Cmd(&opts).render().unwrap();
105105

106106
let assert = Command::new(which::which("cmd.exe").unwrap())
107-
.args(["/d", "/x", "/k"])
107+
.args(["/x", "/d", "/q", "/k", "echo off"])
108+
.env("PROMPT", "")
108109
.write_stdin(source)
109110
.assert()
110-
.success();
111+
.success()
112+
.stderr("");
111113

112-
if opts.hook != InitHook::None {
113-
assert.stderr("zoxide: hooks are not supported on cmd.exe shell.\r\n");
114-
} else {
115-
assert.stderr("");
114+
if opts.hook == InitHook::None {
115+
assert.stdout("");
116116
}
117117
}
118118

@@ -123,15 +123,15 @@ mod tests {
123123
let source = Cmd(&opts).render().unwrap();
124124

125125
let assert = Command::new(which::which("cmd.exe").unwrap())
126-
.args(["/d", "/y", "/k"])
126+
.args(["/y", "/d", "/q", "/k", "echo off"])
127+
.env("PROMPT", "")
127128
.write_stdin(source)
128129
.assert()
129-
.success();
130+
.success()
131+
.stderr("");
130132

131-
if opts.hook != InitHook::None {
132-
assert.stderr("zoxide: hooks are not supported on cmd.exe shell.\r\n");
133-
} else {
134-
assert.stderr("");
133+
if opts.hook == InitHook::None {
134+
assert.stdout("");
135135
}
136136
}
137137

templates/cmd.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33

44
rem Code generated by zoxide. DO NOT EDIT.
55

6-
@if "%=^%=" == "%=%=" (
7-
set \p=%%<nul
8-
) else (
9-
set \p=^%<nul
10-
)
6+
@if "%=^%=" == "%=%=" (set \p=%%<nul) else (set \p=^%<nul)
117

128
set __program=zoxide
139

@@ -19,7 +15,8 @@ rem Hook configuration for zoxide.
1915
rem
2016

2117
{% if hook != InitHook::None -%}
22-
>&2 echo %__program%: hooks are not supported on cmd.exe shell.
18+
echo %__program%: hooks are not supported on cmd.exe shell.
19+
echo Use '%__program% init cmd --hook none' instead.
2320

2421
{%- else -%}
2522
{{ not_configured }}
@@ -60,4 +57,9 @@ rem Jump to a directory using interactive search.
6057
{{ section }}
6158
rem To initialize zoxide, add this to your configuration or AutoRun command:
6259
rem
63-
rem zoxide init cmd --hook none | cmd /d/q/k >nul
60+
rem zoxide init cmd | cmd /d/q/k echo off
61+
62+
{#~
63+
Content piped to `cmd.exe` needs to end with an empty line to indicate end of
64+
input. Removing this will cause extra "More? " to be written to stdout.
65+
#}

0 commit comments

Comments
 (0)