From d4069651b64d3446f6d3e8c11b8583204a7508f4 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 26 Feb 2019 11:43:07 -0500 Subject: [PATCH] hang_processes.sh: Fix some ShellCheck warnings 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 --- scripts/lttng-tools/hang_processes.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/lttng-tools/hang_processes.sh b/scripts/lttng-tools/hang_processes.sh index 6a102b8..0967218 100755 --- a/scripts/lttng-tools/hang_processes.sh +++ b/scripts/lttng-tools/hang_processes.sh @@ -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 -- 2.34.1