Package: lsb-base Version: 3.2-23.1 Severity: wishlist
Do not use unsafe[1] logical operands "-a, -o". Prefer operands "&&, ||" instead [1] http://mywiki.wooledge.org/BashPitfalls#A.5B_.22.24foo.22_.3D_bar_.26.26_.22.24bar.22_.3D_foo_.5D "The problem with [ A = B -a C = D ] (or -o) is that POSIX does not specify the results of a test or [ command with more than 4 arguments. It probably works in most shells, but you can't count on it. You should use two test or [ commands with && between them instead, if you have to write for POSIX shells. If you have to write for Bourne, always use test instead of [." See http://www.opengroup.org/onlinepubs/9699919799/utilities/test.html -- System Information: Debian Release: squeeze/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores) Locale: LANG=en_DK.UTF-8, LC_CTYPE=en_DK.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages lsb-base depends on: ii ncurses-bin 5.7+20100313-4 terminal-related programs and man ii sed 4.2.1-7 The GNU sed stream editor lsb-base recommends no packages. lsb-base suggests no packages. -- no debconf information
>From 24373d3e8de4910a3564ba61c83d972bc5b14b65 Mon Sep 17 00:00:00 2001 From: Jari Aalto <[email protected]> Date: Sun, 31 Oct 2010 23:47:06 +0200 Subject: [PATCH] init-functions: Prefer safer &&, || instead of -a, -o Organization: Private Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Signed-off-by: Jari Aalto <[email protected]> --- init-functions | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/init-functions b/init-functions index 57444b8..6bcb1be 100644 --- a/init-functions +++ b/init-functions @@ -77,7 +77,7 @@ pidofproc () { pidfile="/var/run/$base.pid" fi - if [ -n "${pidfile:-}" -a -r "$pidfile" ]; then + if [ -n "${pidfile:-}" ] && [ -r "$pidfile" ]; then read pid < "$pidfile" if [ -n "${pid:-}" ]; then if $(kill -0 "${pid:-}" 2> /dev/null); then @@ -91,7 +91,7 @@ pidofproc () { fi fi fi - if [ -x /bin/pidof -a ! "$specified" ]; then + if [ -x /bin/pidof ] && [ ! "$specified" ]; then status="0" /bin/pidof -o %PPID -x $1 || status="$?" if [ "$status" = 1 ]; then @@ -129,7 +129,7 @@ killproc () { sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/') sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/') - if [ -z "$sig" -o "$sig" = 15 -o "$sig" = TERM ]; then + if [ -z "$sig" ] || [ "$sig" = 15 ] || [ "$sig" = TERM ]; then is_term_sig=yes fi status=0 @@ -149,7 +149,7 @@ killproc () { return 3 # program is not running fi - if [ "$status" = 0 -a "$is_term_sig" = yes -a "$pidfile" ]; then + if [ "$status" = 0 ] && [ "$is_term_sig" = yes ] && [ "$pidfile" ]; then pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile" fi return 0 -- 1.7.2.3

