1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

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:
Dave Reisner 2013-07-30 12:46:23 -04:00
parent 751e75769a
commit a72d698d0d
9 changed files with 36 additions and 27 deletions

View File

@ -18,9 +18,10 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
}
_hostnamectl() {

View File

@ -18,9 +18,10 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
}
__journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}

View File

@ -18,9 +18,10 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
}
_localectl() {

View File

@ -18,9 +18,10 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
}
__get_all_sessions () { loginctl list-sessions | { while read -r a b; do printf "%s\n" "$a"; done; } ; }

View File

@ -32,9 +32,10 @@ __systemd_properties() {
}
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
}
__filter_units_by_property () {

View File

@ -19,9 +19,10 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
}
_systemd_analyze() {

View File

@ -18,9 +18,10 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
}
__journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}

View File

@ -18,9 +18,10 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
}
_timedatectl() {

View File

@ -18,9 +18,10 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
}
__get_all_sysdevs() {