Skip to content

Commit

Permalink
xe autocompletion: Fix prefix escaping bug (xapi-project#5975)
Browse files Browse the repository at this point in the history
Before, having an escape sequence as part of the parameter would break
grep:
```
$ xe vdi-list name-label=CentOS\ 7\ \(1grep: Unmatched ( or \(
```

Move back to pure bash processing for the prefix, since it's the
weirdness of variable escaping leaving the bash context causing this.
  • Loading branch information
last-genius authored Sep 18, 2024
2 parents 7e9c2a3 + 7cb5d7b commit 739cacf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ocaml/xe-cli/bash-completion
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,10 @@ __add_completion()

__preprocess_suggestions()
{
echo "$1" | \
sed -re 's/(^|[^\])((\\\\)*),,*/\1\2\n/g' -e 's/\\,/,/g' -e 's/\\\\/\\/g' | \
sed -e 's/ *$//' | \
grep "^${prefix}.*"
wordlist=$( echo "$1" | \
sed -re 's/(^|[^\])((\\\\)*),,*/\1\2\n/g' -e 's/\\,/,/g' -e 's/\\\\/\\/g' | \
sed -e 's/ *$//')
compgen -W "$wordlist" "$prefix"
}

# set_completions suggestions current_prefix description_cmd
Expand Down

0 comments on commit 739cacf

Please sign in to comment.