bash-completion: localize words and cword variables
authorSibo Dong <dongsibo@users.noreply.github.com>
Sat, 3 Apr 2021 03:33:59 +0000 (23:33 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 6 Apr 2021 14:15:13 +0000 (16:15 +0200)
commitf34173a048061b3f7e551e9a7c04f00e5a106fac
tree16969104c7d906495094884497ab70324fea2c51
parent7c20dd4b6ef6e69862576722ac69b895d7a92dc9
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.
shell-completion/bash/machinectl
shell-completion/bash/networkctl
shell-completion/bash/systemd-analyze
shell-completion/bash/systemd-cat
shell-completion/bash/systemd-cgls
shell-completion/bash/systemd-cgtop
shell-completion/bash/systemd-delta
shell-completion/bash/systemd-detect-virt
shell-completion/bash/systemd-id128
shell-completion/bash/systemd-nspawn
shell-completion/bash/systemd-path