log_merge: Use shelcheck to harden the script

Change-Id: I1b3a35b5f7ada2dbb0401a5d90a77a53979e1183
This commit is contained in:
Harald Welte 2018-03-18 15:19:33 +01:00
parent e1f9b74602
commit b537461a9c
1 changed files with 5 additions and 5 deletions

View File

@ -7,7 +7,7 @@
# #
# the output files will be called "Module-Testcase.merged" # the output files will be called "Module-Testcase.merged"
if [ "x$1" == "x" ]; then if [ "x$1" = "x" ]; then
echo "You have to specify the Test Suite prefix" echo "You have to specify the Test Suite prefix"
exit 2 exit 2
fi fi
@ -15,16 +15,16 @@ fi
BASE_NAME="$1" BASE_NAME="$1"
LOG_FILES="$BASE_NAME*.log" LOG_FILES="$BASE_NAME*.log"
TEST_CASES=`ls -1 $LOG_FILES | awk 'BEGIN { FS = "-" } { print $2 }' | sort | uniq` TEST_CASES=$(ls -1 $LOG_FILES | awk 'BEGIN { FS = "-" } { print $2 }' | sort | uniq)
for t in $TEST_CASES; do for t in $TEST_CASES; do
PREFIX="$BASE_NAME-$t" PREFIX="$BASE_NAME-$t"
OUTPUT="$BASE_NAME.$t.merged" OUTPUT="$BASE_NAME.$t.merged"
ttcn3_logmerge $PREFIX-*.log > $OUTPUT ttcn3_logmerge $PREFIX-*.log > "$OUTPUT"
echo "Generated $OUTPUT" echo "Generated $OUTPUT"
done done
if [ "$2" == "--rm" ]; then if [ "$2" = "--rm" ]; then
echo "Removing Input log files !!!" echo "Removing Input log files !!!"
rm $LOG_FILES rm "$LOG_FILES"
fi fi