ctdb-scripts: Quote some variable expansions
[nivanova/samba-autobuild/.git] / ctdb / config / debug_locks.sh
index 8e337518aff5cff449f2aedab95739293a7ae250..62b679923409a8b6910d51f4180def53768177a1 100755 (executable)
@@ -8,9 +8,9 @@
 # rather than mutex locks.
 
 [ -n "$CTDB_BASE" ] || \
-    export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
+    CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
 
-. "$CTDB_BASE/functions"
+. "${CTDB_BASE}/functions"
 
 # Default fallback location for database directories.
 # These can be overwritten from CTDB configuration
@@ -36,7 +36,7 @@ loadconfig ctdb
     grep -F "POSIX  ADVISORY  WRITE" |
     awk '{ if($2 == "->") { print $6, $7, $8, $9, "W" } else { print $5, $6, $7, $8 } }' |
     while read pid rest ; do
-       pname=$(readlink /proc/$pid/exe)
+       pname=$(readlink "/proc/${pid}/exe")
        echo $pid $pname $rest
     done | sed -e "$sed_cmd" | grep "\.tdb" )
 
@@ -56,7 +56,7 @@ loadconfig ctdb
        # For each process waiting, log stack trace
        for pid in $pids ; do
            echo "----- Stack trace for PID=$pid -----"
-           read x x state x </proc/$pid/stat
+           read x x state x <"/proc/${pid}/stat"
            if [ "$state" = "D" ] ; then
                # Don't run gstack on a process in D state since
                # gstack will hang until the process exits D state.
@@ -68,9 +68,9 @@ loadconfig ctdb
                # deadlock... but it will probably give us someone to
                # blame!
                echo "----- Process in D state, printing kernel stack only"
-               cat /proc/$pid/stack
+               cat "/proc/${pid}/stack"
            else
-               gstack $pid
+               gstack "$pid"
                # gcore -o /var/log/core-deadlock-ctdb $pid
            fi
        done