]> Untitled Git - hvutilities.git/commitdiff
tarbz2: use hvutilities log functions
authorHugo Villeneuve <hugo@hugovil.com>
Wed, 1 Apr 2026 17:01:47 +0000 (13:01 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Thu, 2 Apr 2026 23:34:04 +0000 (19:34 -0400)
Signed-off-by: Hugo Villeneuve <hugo@hugovil.com>
scripts/tarbz2

index 3ea891cd1fe58f7f158adc8451d84ee772b1dc21..2672c654cf6fdbc65e95d65596296042506df7f8 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
-PROG_NAME=$(basename $0)
+PROG_NAME="`readlink -e $0`"
+PROG_PATH=$(dirname ${PROG_NAME})
+. ${PROG_PATH}/hvutilities.sh
 
 BZIP2_BIN=bzip2
 
@@ -17,19 +19,20 @@ print_usage()
     echo "                  Default is same name as the input directory."
 }
 
-while getopts "hf:" flag ;do
+while getopts "hf:" flagdo
     case ${flag} in
-       h)
-           print_usage
-           ;;
-       f)
-           DEST=${OPTARG}
-           ;;
-       ?)
-           echo "${PROG_NAME}: Invalid option: ${OPTARG}."
-           echo "Try \`${PROG_NAME} --help' for more information."
-           exit 1
+        h)
+            print_usage
+            exit 0
            ;;
+        f)
+            DEST=${OPTARG}
+            ;;
+        ?)
+            log_err "${PROG_NAME}: Invalid option: ${OPTARG}."
+            log_err "Try \`${PROG_NAME} --help' for more information."
+            exit 1
+            ;;
     esac
 done
 shift `expr "${OPTIND}" - 1`
@@ -37,12 +40,12 @@ shift `expr "${OPTIND}" - 1`
 # `$#' now represents the number of arguments after the options.
 # `$1' is the first argument, etc.
 if [ ${#} -eq 0 ]; then
-    echo "${PROG_NAME}: Missing source directory."
-    echo "Try \`${PROG_NAME} --help' for more information."
+    log_err "${PROG_NAME}: Missing source directory."
+    log_err "Try \`${PROG_NAME} --help' for more information."
     exit 1
 elif [ ${#} -gt 1 ]; then
-    echo "${PROG_NAME}: Too many arguments."
-    echo "Try \`${PROG_NAME} --help' for more information."
+    log_err "${PROG_NAME}: Too many arguments."
+    log_err "Try \`${PROG_NAME} --help' for more information."
     exit 1
 fi
 
@@ -50,7 +53,7 @@ DIR=${1%/}
 
 # Checking if directory exists.
 if [ ! -d ${DIR} ]; then
-    echo "$0: Directory ${DIR} not found."
+    log_err "$0: Directory ${DIR} not found."
     exit 1
 fi