From a9ed60fa32f97dca8920575a7f916075feca3f3a Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Fri, 18 Mar 2022 13:34:44 +0100 Subject: [PATCH] fix: proper use of -h flag --- EOPSY/task1/modify.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/EOPSY/task1/modify.sh b/EOPSY/task1/modify.sh index ca43b5fa..8ffe3757 100755 --- a/EOPSY/task1/modify.sh +++ b/EOPSY/task1/modify.sh @@ -1,14 +1,19 @@ #!/bin/bash +# Function to detect -h flag and show help for this script show_help() { - local OPTIND + local OPTIND while getopts ":h" opt ; do - echo "This script modifies file names" - echo "-l lowerize file names" - echo "-u uppercase file names" - echo "-r recurse into directory" - echo "[-r] specify sed pattern that will be executed on file names" - echo "-h show this help information" + case "$opt" in + h ) + echo "This script modifies file names" + echo "-l lowerize file names" + echo "-u uppercase file names" + echo "-r recurse into directory" + echo "[-r] specify sed pattern that will be executed on file names" + echo "-h show this help information" + ;; + esac done }