summaryrefslogtreecommitdiffstats
path: root/shell-completion
diff options
context:
space:
mode:
authorSibo Dong <dongsibo@users.noreply.github.com>2021-04-03 05:33:59 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-04-06 16:15:13 +0200
commitf34173a048061b3f7e551e9a7c04f00e5a106fac (patch)
tree16969104c7d906495094884497ab70324fea2c51 /shell-completion
parentsysusers/firstboot: temporarily disable LoadCredential (diff)
downloadsystemd-f34173a048061b3f7e551e9a7c04f00e5a106fac.tar.xz
systemd-f34173a048061b3f7e551e9a7c04f00e5a106fac.zip
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.
Diffstat (limited to 'shell-completion')
-rw-r--r--shell-completion/bash/machinectl2
-rw-r--r--shell-completion/bash/networkctl2
-rw-r--r--shell-completion/bash/systemd-analyze2
-rw-r--r--shell-completion/bash/systemd-cat2
-rw-r--r--shell-completion/bash/systemd-cgls2
-rw-r--r--shell-completion/bash/systemd-cgtop2
-rw-r--r--shell-completion/bash/systemd-delta2
-rw-r--r--shell-completion/bash/systemd-detect-virt2
-rw-r--r--shell-completion/bash/systemd-id1282
-rw-r--r--shell-completion/bash/systemd-nspawn2
-rw-r--r--shell-completion/bash/systemd-path2
11 files changed, 11 insertions, 11 deletions
diff --git a/shell-completion/bash/machinectl b/shell-completion/bash/machinectl
index cd16e47721..bc3a7889b3 100644
--- a/shell-completion/bash/machinectl
+++ b/shell-completion/bash/machinectl
@@ -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=(
diff --git a/shell-completion/bash/networkctl b/shell-completion/bash/networkctl
index 9282ee8737..ab2a5f7015 100644
--- a/shell-completion/bash/networkctl
+++ b/shell-completion/bash/networkctl
@@ -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'
diff --git a/shell-completion/bash/systemd-analyze b/shell-completion/bash/systemd-analyze
index 92f81a60fc..eded49b50e 100644
--- a/shell-completion/bash/systemd-analyze
+++ b/shell-completion/bash/systemd-analyze
@@ -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
diff --git a/shell-completion/bash/systemd-cat b/shell-completion/bash/systemd-cat
index 9413b6fa70..737f33981b 100644
--- a/shell-completion/bash/systemd-cat
+++ b/shell-completion/bash/systemd-cat
@@ -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=(
diff --git a/shell-completion/bash/systemd-cgls b/shell-completion/bash/systemd-cgls
index 7caaf89ddb..0b6a8fda0d 100644
--- a/shell-completion/bash/systemd-cgls
+++ b/shell-completion/bash/systemd-cgls
@@ -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=(
diff --git a/shell-completion/bash/systemd-cgtop b/shell-completion/bash/systemd-cgtop
index b186f1bd53..2c59b6c9f6 100644
--- a/shell-completion/bash/systemd-cgtop
+++ b/shell-completion/bash/systemd-cgtop
@@ -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=(
diff --git a/shell-completion/bash/systemd-delta b/shell-completion/bash/systemd-delta
index baf86b0813..f97b6dd5b2 100644
--- a/shell-completion/bash/systemd-delta
+++ b/shell-completion/bash/systemd-delta
@@ -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=(
diff --git a/shell-completion/bash/systemd-detect-virt b/shell-completion/bash/systemd-detect-virt
index fb35efaadb..0c9da3a22e 100644
--- a/shell-completion/bash/systemd-detect-virt
+++ b/shell-completion/bash/systemd-detect-virt
@@ -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=(
diff --git a/shell-completion/bash/systemd-id128 b/shell-completion/bash/systemd-id128
index 937556154a..25110d1309 100644
--- a/shell-completion/bash/systemd-id128
+++ b/shell-completion/bash/systemd-id128
@@ -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'
diff --git a/shell-completion/bash/systemd-nspawn b/shell-completion/bash/systemd-nspawn
index ebd97a9de1..ed1296a878 100644
--- a/shell-completion/bash/systemd-nspawn
+++ b/shell-completion/bash/systemd-nspawn
@@ -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=(
diff --git a/shell-completion/bash/systemd-path b/shell-completion/bash/systemd-path
index cae4ac1b30..4330c3e05b 100644
--- a/shell-completion/bash/systemd-path
+++ b/shell-completion/bash/systemd-path
@@ -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'