From 6bc21456127bcaa1504f5700c55a3fe46ea6da6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Mon, 2 Mar 2026 15:33:43 +0100 Subject: [PATCH] Add help information upon misuse. --- countdown.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/countdown.sh b/countdown.sh index 717ebe1..ffea337 100755 --- a/countdown.sh +++ b/countdown.sh @@ -22,16 +22,19 @@ # 3. This notice may not be removed or altered from any source # distribution. -if [ -z $1 ] +set -euo pipefail + +if [ $? -gt 1 ] then - COUNT=5 -else - COUNT=$1 + echo "Usage: $0 [COUNT]" + exit 1 fi -for i in $(seq $COUNT -1 1) +COUNT=${1:-5} + +for i in $(seq "$COUNT" -1 1) do - echo $i + echo "$i" sleep 1 done