Skip to content

Commit 2e217f8

Browse files
shaneturnerfengmk2
andauthored
fix(cli): wrap zsh completion in eval for dash compatibility (#1280)
#### Description Fixes an issue where Ubuntu desktop login fails because the generated `~/.vite-plus/env` file contains Zsh-specific array syntax that is incompatible with the POSIX `dash` shell used during login. #### Changes - Wrapped Zsh completion logic in an `eval` block in `crates/vite_global_cli/src/commands/env/setup.rs`. - Updated unit tests to check for the `eval` wrapper. #### Verification - Manually verified the snippet using `dash` (POSIX compliant). - Note: Full `pnpm test` was blocked by upstream `fspy` compilation issues, but the fix follows the standard shell-portability pattern used in similar projects (e.g., nvm). Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>
1 parent feefa31 commit 2e217f8

File tree

1 file changed

+6
-0
lines changed
  • crates/vite_global_cli/src/commands/env

1 file changed

+6
-0
lines changed

crates/vite_global_cli/src/commands/env/setup.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,15 @@ if [ -n "$BASH_VERSION" ] && type complete >/dev/null 2>&1; then
449449
eval "$(VP_COMPLETE=bash command vp)"
450450
elif [ -n "$ZSH_VERSION" ] && type compdef >/dev/null 2>&1; then
451451
eval "$(VP_COMPLETE=zsh command vp)"
452+
eval '
452453
_vpr_complete() {
453454
local -a orig=("${words[@]}")
454455
words=("vp" "run" "${orig[@]:1}")
455456
CURRENT=$((CURRENT + 1))
456457
${=_comps[vp]}
457458
}
458459
compdef _vpr_complete vpr
460+
'
459461
fi
460462
"#
461463
.replace("__VP_BIN__", &bin_path_ref);
@@ -918,6 +920,10 @@ mod tests {
918920
env_content.contains("compdef _vpr_complete vpr"),
919921
"env should have vpr completion for zsh"
920922
);
923+
assert!(
924+
env_content.contains("eval '") && env_content.contains("_vpr_complete() {"),
925+
"env should wrap zsh-specific code in eval"
926+
);
921927
assert!(fish_content.contains("complete -c vpr"), "env.fish should have vpr completion");
922928
assert!(
923929
ps1_content.contains("Register-ArgumentCompleter -Native -CommandName vpr"),

0 commit comments

Comments
 (0)