mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
bash-completion: localize words and cword variables
The words and cword variables are not localized in all Bash completion scripts that call _init_completion. cur, prev, words, and cword (and split if using the -s flag) are all variables that should be localized in Bash completion scripts before calling _init_completion (even if they don't otherwise appear in the calling script). This is done for cur and prev, but not for words and cword. Letting words and cword remain unlocalized may clobber variables the user is using for other purposes, which is bad. This issue can be resolved by declaring words and cword as local variables. Resolves #19188.
This commit is contained in:
parent
7c20dd4b6e
commit
f34173a048
@ -30,7 +30,7 @@ __get_machines() {
|
||||
}
|
||||
|
||||
_machinectl() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local i verb comps
|
||||
|
||||
local -A OPTS=(
|
||||
|
@ -30,7 +30,7 @@ __get_links() {
|
||||
|
||||
_networkctl() {
|
||||
local i verb comps
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-a --all -h --help --version --no-pager --no-legend -s --stats -l --full'
|
||||
[ARG]='-n --lines'
|
||||
|
@ -46,7 +46,7 @@ __get_syscall_sets() {
|
||||
|
||||
_systemd_analyze() {
|
||||
local i verb comps mode
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-h --help --version --system --user --global --order --require --no-pager
|
||||
|
@ -25,7 +25,7 @@ __contains_word() {
|
||||
}
|
||||
|
||||
_systemd_cat() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local i verb comps
|
||||
|
||||
local -A OPTS=(
|
||||
|
@ -37,7 +37,7 @@ __get_units_have_cgroup() {
|
||||
}
|
||||
|
||||
_systemd_cgls() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local i verb comps
|
||||
|
||||
local -A OPTS=(
|
||||
|
@ -29,7 +29,7 @@ __get_machines() {
|
||||
}
|
||||
|
||||
_systemd_cgtop() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local comps
|
||||
|
||||
local -A OPTS=(
|
||||
|
@ -24,7 +24,7 @@ __contains_word() {
|
||||
}
|
||||
|
||||
_systemd-delta() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local comps
|
||||
|
||||
local -A OPTS=(
|
||||
|
@ -24,7 +24,7 @@ __contains_word() {
|
||||
}
|
||||
|
||||
_systemd_detect_virt() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local i verb comps
|
||||
|
||||
local -A OPTS=(
|
||||
|
@ -26,7 +26,7 @@ __contains_word () {
|
||||
|
||||
_systemd_id128() {
|
||||
local i verb comps
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-h --help --version -p --pretty'
|
||||
[ARG]='-a --app-specific'
|
||||
|
@ -58,7 +58,7 @@ __get_rlimit() {
|
||||
}
|
||||
|
||||
_systemd_nspawn() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local i verb comps
|
||||
|
||||
local -A OPTS=(
|
||||
|
@ -30,7 +30,7 @@ __get_names() {
|
||||
|
||||
_systemd_path() {
|
||||
local comps
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-h --help --version'
|
||||
[ARG]='--suffix'
|
||||
|
Loading…
Reference in New Issue
Block a user