hang_processes.sh: Fix some ShellCheck warnings
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 26 Feb 2019 16:43:07 +0000 (11:43 -0500)
committerJonathan Rajotte Julien <jonathan.rajotte-julien@efficios.com>
Tue, 26 Feb 2019 16:51:57 +0000 (11:51 -0500)
Specifically:

In hang_processes.sh line 29:
if [ ! -z "$lttng_processes" ]; then
     ^-- SC2236: Use -n instead of ! -z.

In hang_processes.sh line 54:
if [ ! -z "$core_files" ]; then
     ^-- SC2236: Use -n instead of ! -z.

In hang_processes.sh line 67:
    rm -rf $core_files
           ^---------^ SC2086: Double quote to prevent globbing and word splitting.

I also removed the -r on the rm.  Since we are not deleting directories (and it
seems safer not to use -rf if we don't need to, in case $core_files contains
the wrong thing).

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
scripts/lttng-tools/hang_processes.sh

index 6a102b89d3926e6527f7f4671b2bfa468c39c154..09672182b06f7012fff598c180a9b13b7103d205 100755 (executable)
@@ -26,7 +26,7 @@ ret=0
 WORKSPACE=${WORKSPACE:-$PWD}
 
 lttng_processes="$("$PGREP" -l 'lttng|gen-ust-.+')" || true
-if [ ! -z "$lttng_processes" ]; then
+if [ -n "$lttng_processes" ]; then
 
     pids="$(cut -d ' ' -f 1 <<< "$lttng_processes" | tr '\n' ' ')"
     echo "The following LTTng processes were detected running on the system and will be aborted:"
@@ -51,7 +51,7 @@ if [ ! -z "$lttng_processes" ]; then
 fi
 
 core_files=$(find "/tmp" -name "core\.[0-9]*" -type f 2>/dev/null) || true
-if [ ! -z "$core_files" ]; then
+if [ -n "$core_files" ]; then
     echo "$core_files" >> "$file_list"
     echo "$dependencies" >> "$file_list"
 
@@ -64,7 +64,7 @@ if [ ! -z "$core_files" ]; then
 
     mkdir -p "${WORKSPACE}/build"
     tar cfzh "${WORKSPACE}/build/core.tar.gz" -T "$file_list"
-    rm -rf $core_files
+    rm -f "$core_files"
     ret=1
 fi
 
This page took 0.028766 seconds and 4 git commands to generate.