diff options
author | Carsten Hey <carsten@debian.org> | 2015-12-07 18:48:20 +0100 |
---|---|---|
committer | Matthias Klumpp <matthias@tenstral.net> | 2015-12-07 18:48:28 +0100 |
commit | fe023b090764c1201955bab3bd3277ff9426196c (patch) | |
tree | 7eda5ec55771e5176861cf5e3272cd52ff9b1f68 /contrib | |
parent | 3ad2c60fc9059998f314df33b59c97eb2f237782 (diff) |
cnf: use the [[ compound command all around
Using [ $VARIABLE ], i.e., neither is [[ used, nor is the variable
quoted, leads to errors like this one:
$ FOOBAR='! true'
$ [ $FOOBAR ] && echo FOOBAR is set and not empty \
|| echo FOOBAR is unset or empty
FOOBAR is unset or empty
Correct would, for instance, be:
$ FOOBAR='! true'
$ [[ $FOOBAR ]] && echo FOOBAR is set and not empty \
|| echo FOOBAR is unset or empty
FOOBAR is set and not empty
And the bash version used to demonstrate this is:
$ echo $BASH_VERSION
4.3.30(1)-release
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/command-not-found/PackageKit.sh.in | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/contrib/command-not-found/PackageKit.sh.in b/contrib/command-not-found/PackageKit.sh.in index c130ce45f..3fbc819f0 100644 --- a/contrib/command-not-found/PackageKit.sh.in +++ b/contrib/command-not-found/PackageKit.sh.in @@ -14,13 +14,13 @@ command_not_found_handle () { [[ $- =~ i ]] || runcnf=0 # don't run if DBus isn't running - [ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0 + [[ ! -S /var/run/dbus/system_bus_socket ]] && runcnf=0 # don't run if packagekitd doesn't exist in the _system_ root - [ ! -x @LIBEXECDIR@/packagekitd ] && runcnf=0 + [[ ! -x @LIBEXECDIR@/packagekitd ]] && runcnf=0 # don't run if bash command completion is being run - [ ${COMP_CWORD-} ] && runcnf=0 + [[ -n ${COMP_CWORD-} ]] && runcnf=0 # run the command, or just print a warning if [ $runcnf -eq 1 ]; then |