bash-completion: use a better definition of __contains_word
- scope the iterator var - use the correct, quoted, non-expansion prone positional parameter notation - prevent expansion on RHS of comparison - remove unneeded explicit returns. This really should be defined only once...
This commit is contained in:
parent
751e75769a
commit
a72d698d0d
|
@ -18,9 +18,10 @@
|
||||||
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__contains_word () {
|
__contains_word () {
|
||||||
local word=$1; shift
|
local w word=$1; shift
|
||||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
for w in "$@"; do
|
||||||
return 1
|
[[ $w = "$word" ]] && return
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
_hostnamectl() {
|
_hostnamectl() {
|
||||||
|
|
|
@ -18,9 +18,10 @@
|
||||||
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__contains_word () {
|
__contains_word () {
|
||||||
local word=$1; shift
|
local w word=$1; shift
|
||||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
for w in "$@"; do
|
||||||
return 1
|
[[ $w = "$word" ]] && return
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
__journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
|
__journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
|
||||||
|
|
|
@ -18,9 +18,10 @@
|
||||||
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__contains_word () {
|
__contains_word () {
|
||||||
local word=$1; shift
|
local w word=$1; shift
|
||||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
for w in "$@"; do
|
||||||
return 1
|
[[ $w = "$word" ]] && return
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
_localectl() {
|
_localectl() {
|
||||||
|
|
|
@ -18,9 +18,10 @@
|
||||||
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__contains_word () {
|
__contains_word () {
|
||||||
local word=$1; shift
|
local w word=$1; shift
|
||||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
for w in "$@"; do
|
||||||
return 1
|
[[ $w = "$word" ]] && return
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
__get_all_sessions () { loginctl list-sessions | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
|
__get_all_sessions () { loginctl list-sessions | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
|
||||||
|
|
|
@ -32,9 +32,10 @@ __systemd_properties() {
|
||||||
}
|
}
|
||||||
|
|
||||||
__contains_word () {
|
__contains_word () {
|
||||||
local word=$1; shift
|
local w word=$1; shift
|
||||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
for w in "$@"; do
|
||||||
return 1
|
[[ $w = "$word" ]] && return
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
__filter_units_by_property () {
|
__filter_units_by_property () {
|
||||||
|
|
|
@ -19,9 +19,10 @@
|
||||||
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__contains_word () {
|
__contains_word () {
|
||||||
local word=$1; shift
|
local w word=$1; shift
|
||||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
for w in "$@"; do
|
||||||
return 1
|
[[ $w = "$word" ]] && return
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
_systemd_analyze() {
|
_systemd_analyze() {
|
||||||
|
|
|
@ -18,9 +18,10 @@
|
||||||
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__contains_word () {
|
__contains_word () {
|
||||||
local word=$1; shift
|
local w word=$1; shift
|
||||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
for w in "$@"; do
|
||||||
return 1
|
[[ $w = "$word" ]] && return
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
__journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
|
__journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
|
||||||
|
|
|
@ -18,9 +18,10 @@
|
||||||
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__contains_word () {
|
__contains_word () {
|
||||||
local word=$1; shift
|
local w word=$1; shift
|
||||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
for w in "$@"; do
|
||||||
return 1
|
[[ $w = "$word" ]] && return
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
_timedatectl() {
|
_timedatectl() {
|
||||||
|
|
|
@ -18,9 +18,10 @@
|
||||||
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__contains_word () {
|
__contains_word () {
|
||||||
local word=$1; shift
|
local w word=$1; shift
|
||||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
for w in "$@"; do
|
||||||
return 1
|
[[ $w = "$word" ]] && return
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
__get_all_sysdevs() {
|
__get_all_sysdevs() {
|
||||||
|
|
Loading…
Reference in a new issue