summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-07-30 12:46:23 -0400
committerDave Reisner <dreisner@archlinux.org>2013-07-30 13:04:46 -0400
commita72d698d0d9ff9c158155b44cdc77376df31a317 (patch)
tree3c80960a1404b44df57b200208664c206f96d8cf
parent751e75769a0a8a255e1a47656f639768879e9518 (diff)
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...
-rw-r--r--shell-completion/bash/hostnamectl7
-rw-r--r--shell-completion/bash/journalctl7
-rw-r--r--shell-completion/bash/localectl7
-rw-r--r--shell-completion/bash/loginctl7
-rw-r--r--shell-completion/bash/systemctl7
-rw-r--r--shell-completion/bash/systemd-analyze7
-rw-r--r--shell-completion/bash/systemd-coredumpctl7
-rw-r--r--shell-completion/bash/timedatectl7
-rw-r--r--shell-completion/bash/udevadm7
9 files changed, 36 insertions, 27 deletions
diff --git a/shell-completion/bash/hostnamectl b/shell-completion/bash/hostnamectl
index a57bffe15..38ab1344f 100644
--- a/shell-completion/bash/hostnamectl
+++ b/shell-completion/bash/hostnamectl
@@ -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() {
diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl
index 29bf6bca3..3c40d57a9 100644
--- a/shell-completion/bash/journalctl
+++ b/shell-completion/bash/journalctl
@@ -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}
diff --git a/shell-completion/bash/localectl b/shell-completion/bash/localectl
index ef19f0146..bec9e78c6 100644
--- a/shell-completion/bash/localectl
+++ b/shell-completion/bash/localectl
@@ -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() {
diff --git a/shell-completion/bash/loginctl b/shell-completion/bash/loginctl
index 1844085d4..3104b305f 100644
--- a/shell-completion/bash/loginctl
+++ b/shell-completion/bash/loginctl
@@ -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; } ; }
diff --git a/shell-completion/bash/systemctl b/shell-completion/bash/systemctl
index ceca3348e..517b49a6a 100644
--- a/shell-completion/bash/systemctl
+++ b/shell-completion/bash/systemctl
@@ -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 () {
diff --git a/shell-completion/bash/systemd-analyze b/shell-completion/bash/systemd-analyze
index 11276ef09..33833aac1 100644
--- a/shell-completion/bash/systemd-analyze
+++ b/shell-completion/bash/systemd-analyze
@@ -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() {
diff --git a/shell-completion/bash/systemd-coredumpctl b/shell-completion/bash/systemd-coredumpctl
index 4bbece734..805e84824 100644
--- a/shell-completion/bash/systemd-coredumpctl
+++ b/shell-completion/bash/systemd-coredumpctl
@@ -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}
diff --git a/shell-completion/bash/timedatectl b/shell-completion/bash/timedatectl
index 2842b3106..c6a654525 100644
--- a/shell-completion/bash/timedatectl
+++ b/shell-completion/bash/timedatectl
@@ -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() {
diff --git a/shell-completion/bash/udevadm b/shell-completion/bash/udevadm
index e9ad17920..e521a3bbb 100644
--- a/shell-completion/bash/udevadm
+++ b/shell-completion/bash/udevadm
@@ -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() {