From 198939440ada6ae990ba514893b6509adf1a93a6 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Wed, 1 Apr 2026 13:01:47 -0400 Subject: [PATCH] tarbz2: use hvutilities log functions Signed-off-by: Hugo Villeneuve --- scripts/tarbz2 | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/scripts/tarbz2 b/scripts/tarbz2 index 3ea891c..2672c65 100755 --- a/scripts/tarbz2 +++ b/scripts/tarbz2 @@ -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:" flag; do 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 -- 2.47.3