Skip to content

Commit

Permalink
fix(complete): Fix env leakage in elvish dynamic completion
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4452852 committed Jan 7, 2025
1 parent e5f1f48 commit 33b1fc3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions clap_complete/src/env/shells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,10 @@ impl EnvCompleter for Elvish {

let script = r#"
set edit:completion:arg-completer[BIN] = { |@words|
set E:_CLAP_IFS = "\n"
var index = (count $words)
set index = (- $index 1)
set E:_CLAP_COMPLETE_INDEX = (to-string $index)
set E:VAR = "elvish"
put (COMPLETER -- $@words) | to-lines
put (env _CLAP_IFS="\n" _CLAP_COMPLETE_INDEX=(to-string $index) VAR="elvish" COMPLETER -- $@words) | to-lines
}
"#
.replace("COMPLETER", &completer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ set edit:rprompt = (constantly "")
set edit:prompt = (constantly "% ")

set edit:completion:arg-completer[exhaustive] = { |@words|
set E:_CLAP_IFS = "\n"

var index = (count $words)
set index = (- $index 1)
set E:_CLAP_COMPLETE_INDEX = (to-string $index)
set E:COMPLETE = "elvish"

put (exhaustive -- $@words) | to-lines
put (env _CLAP_IFS="\n" _CLAP_COMPLETE_INDEX=(to-string $index) COMPLETE="elvish" exhaustive -- $@words) | to-lines
}


0 comments on commit 33b1fc3

Please sign in to comment.