From 94b069059465386967247a34c7b1d0518da16ebe Mon Sep 17 00:00:00 2001 From: Reto Kromer Date: Sat, 8 Oct 2016 12:10:19 +0200 Subject: [PATCH] New version using getopts ... as in the other amiaopensource repository. --- check_framemd5.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/check_framemd5.sh b/check_framemd5.sh index e6b8a5e..55a195a 100644 --- a/check_framemd5.sh +++ b/check_framemd5.sh @@ -38,17 +38,15 @@ EOF } while getopts ":hi:m:" opt; do - case $opt in + case "${opt}" in h) _output_help ;; i) input_file=$OPTARG ;; m) input_hash=$OPTARG ;; - *) echo "bad option -${OPTARG}" ; _output_prompt ;; - :) echo "Option -${OPTARG} requires an argument" ; _output_prompt ;; + *) echo -e "${RED}Error:${NC }bad option -${OPTARG}" ; _output_prompt ;; + :) echo -e "${RED}Error:${NC} option -${OPTARG} requires an argument" ; _output_prompt ;; esac done -[ -z "$@" ] && _output_prompt - echo -e "${BLUE}Please wait...${NC}" unset md5_tmp if [[ $OSTYPE = "cygwin" ]]; then @@ -57,9 +55,7 @@ else md5_tmp="${HOME}/$(basename ${input_hash}).tmp" fi $(ffmpeg -i ${input_file} -loglevel 0 -f framemd5 -an ${md5_tmp}) -if [[ ! -f ${md5_tmp} ]]; then - echo -e "${RED}ERROR:${NC} '$(basename ${input_file})' is not an audio-visual file." - _output_prompt +[[ ! -f ${md5_tmp} ]] && _output_prompt fi old_file=$(grep -v '^#' ${input_hash}) tmp_file=$(grep -v '^#' ${md5_tmp})