mirror of
https://github.com/amiaopensource/ffmprovisr.git
synced 2025-01-25 01:15:01 +01:00
getopts version
- corrected testing order - unset variables - improved error handling
This commit is contained in:
parent
323da702c0
commit
537d6c54ff
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
SCRIPT=$(basename "${0}")
|
SCRIPT=$(basename "${0}")
|
||||||
VERSION='2016-10-08'
|
VERSION='2016-10-09'
|
||||||
AUTHOR='ffmprovisr'
|
AUTHOR='ffmprovisr'
|
||||||
RED='\033[1;31m'
|
RED='\033[1;31m'
|
||||||
BLUE='\033[1;34m'
|
BLUE='\033[1;34m'
|
||||||
@ -37,17 +37,20 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset input_file
|
||||||
|
unset input_hash
|
||||||
|
|
||||||
while getopts ":hi:m:" opt; do
|
while getopts ":hi:m:" opt; do
|
||||||
case "${opt}" in
|
case "${opt}" in
|
||||||
h) _output_help ;;
|
h) _output_help ;;
|
||||||
i) input_file=$OPTARG ;;
|
i) input_file=$OPTARG ;;
|
||||||
m) input_hash=$OPTARG ;;
|
m) input_hash=$OPTARG ;;
|
||||||
*) echo -e "${RED}Error:${NC }bad option -${OPTARG}" ; _output_prompt ;;
|
|
||||||
:) echo -e "${RED}Error:${NC} option -${OPTARG} requires an argument" ; _output_prompt ;;
|
:) echo -e "${RED}Error:${NC} option -${OPTARG} requires an argument" ; _output_prompt ;;
|
||||||
|
*) echo -e "${RED}Error:${NC }bad option -${OPTARG}" ; _output_prompt ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -z "${@}" ] && _output_prompt
|
[[ -z "${#}" || ! ${input_file} || ! ${input_hash} ]] && _output_prompt
|
||||||
echo -e "${BLUE}Please wait...${NC}"
|
echo -e "${BLUE}Please wait...${NC}"
|
||||||
unset md5_tmp
|
unset md5_tmp
|
||||||
if [[ $OSTYPE = "cygwin" ]]; then
|
if [[ $OSTYPE = "cygwin" ]]; then
|
||||||
@ -56,7 +59,9 @@ else
|
|||||||
md5_tmp="${HOME}/$(basename ${input_hash}).tmp"
|
md5_tmp="${HOME}/$(basename ${input_hash}).tmp"
|
||||||
fi
|
fi
|
||||||
$(ffmpeg -i ${input_file} -loglevel 0 -f framemd5 -an ${md5_tmp})
|
$(ffmpeg -i ${input_file} -loglevel 0 -f framemd5 -an ${md5_tmp})
|
||||||
[[ ! -f ${md5_tmp} ]] && _output_prompt
|
[[ ! -f ${md5_tmp} ]] && { echo -e "${RED}Error:${NC} '${input_file}' is not a valid audio-visual file."; _output_prompt; }
|
||||||
|
unset old_file
|
||||||
|
unset tmp_file
|
||||||
old_file=$(grep -v '^#' ${input_hash})
|
old_file=$(grep -v '^#' ${input_hash})
|
||||||
tmp_file=$(grep -v '^#' ${md5_tmp})
|
tmp_file=$(grep -v '^#' ${md5_tmp})
|
||||||
if [[ "${old_file}" = "${tmp_file}" ]]; then
|
if [[ "${old_file}" = "${tmp_file}" ]]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user