Package: lsb-base
Version: 3.2-23.1
Severity: wishlist

The patch proposes to use better values for variables.

The descriptive values can better document program flow during "sh -x"
testing; they provide better information than "1, yes, no" in shell
scripts.

A demonstration:

    -----------------------------------------------------------------------

    #!/bin/sh
    set -x

    force=1
    verbose=1

    if [ "$force" ] && [ "$verbose" ]; then
        : # Do something
    fi

    force="force"
    verbose="verbose"

    if [ "$force" ] && [ "$verbose" ]; then
        : # Do something
    fi

    # End of file

    -----------------------------------------------------------------------

    $ sh test.sh
    + force=1
    + verbose=1
    + [ 1 ]
    + [ 1 ]
    + :
    + force=force
    + verbose=verbose
    + [ force ]
    + [ verbose ]
    + :


-- 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 d3be8a79da203e0b5e5a3e02ff4a4992768563a8 Mon Sep 17 00:00:00 2001
From: Jari Aalto <[email protected]>
Date: Sun, 31 Oct 2010 23:44:51 +0200
Subject: [PATCH] init-functions: Use self documenting values ready for sh -x
Organization: Private
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit


Signed-off-by: Jari Aalto <[email protected]>
---
 init-functions |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/init-functions b/init-functions
index dfb49e9..037fbbb 100644
--- a/init-functions
+++ b/init-functions
@@ -29,14 +29,14 @@
 
 start_daemon () {
     local force nice pidfile exec i args
-    force=0
+    force=""
     nice=0
     pidfile=/dev/null
 
     OPTIND=1
     while getopts fn:p: opt ; do
         case "$opt" in
-            f)  force=1;;
+            f)  force="force" ;;
             n)  nice="$OPTARG";;
             p)  pidfile="$OPTARG";;
         esac
@@ -50,7 +50,7 @@ start_daemon () {
     exec="$1"; shift
 
     args="--start --nicelevel $nice --quiet --oknodo"
-    if [ $force = 1 ]; then
+    if [ "$force" ]; then
         /sbin/start-stop-daemon $args --chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@"
     elif [ $pidfile ]; then
         /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@"
@@ -68,7 +68,7 @@ pidofproc () {
     while getopts p: opt ; do
         case "$opt" in
             p)  pidfile="$OPTARG"
-                specified=1
+                specified="specified"
 		;;
         esac
     done
@@ -112,7 +112,7 @@ killproc () {
     local pidfile sig status base i name_param is_term_sig
     pidfile=
     name_param=
-    is_term_sig=no
+    is_term_sig=
 
     OPTIND=1
     while getopts p: opt ; do
@@ -132,10 +132,10 @@ 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
-        is_term_sig=yes
+        is_term_sig="terminate_signal"
     fi
     status=0
-    if [ ! "$is_term_sig" = yes ]; then
+    if [ ! "$is_term_sig" ]; then
         if [ -n "$sig" ]; then
             /sbin/start-stop-daemon --stop --signal "$sig" --quiet $name_param || status="$?"
         else
@@ -151,7 +151,7 @@ killproc () {
         return 3 # program is not running
     fi
 
-    if [ "$status" = 0 -a "$is_term_sig" = yes -a "$pidfile" ]; then
+    if [ "$status" = 0 -a "$is_term_sig" -a "$pidfile" ]; then
         pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile"
     fi
     return 0
-- 
1.7.2.3

Reply via email to