From a47fed2080851f716963bed343bcb590b1b51f04 Mon Sep 17 00:00:00 2001 From: C-Duv <1466273+C-Duv@users.noreply.github.com> Date: Thu, 2 Jan 2020 00:35:42 +0100 Subject: [PATCH] [Shell] qa(bash): Sets "e" and "u" Shell options This commits sets the "e" and "u" Shell options for better error handling. Because of "u", an additional test is required before using variable $1. --- send-notification.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/send-notification.sh b/send-notification.sh index 1ba25db..fb8af3e 100644 --- a/send-notification.sh +++ b/send-notification.sh @@ -10,6 +10,7 @@ # # Possible usages: see usage_help() +set -eu readonly PROGNAME=$(basename $0) readonly PROGDIR=$(readlink -m $(dirname $0)) @@ -119,7 +120,7 @@ fi ## MESSAGE_TO_SEND="" -if [ "${1}" ]; then # Message en tant qu'argument de la ligne de commande +if [ $# -ge 1 ] && [ "${1}" ]; then # Message en tant qu'argument de la ligne de commande MESSAGE_TO_SEND="${1}" else # Message lu de STDIN while read line