This commit is contained in:
Reto Kromer 2017-07-08 12:48:15 +02:00 committed by GitHub
parent c81827d98f
commit 7fe503d324

View File

@ -1,19 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SCRIPT=$(basename "${0}") SCRIPT=$(basename "${0}")
VERSION='2017-04-17' VERSION='2017-07-08'
AUTHOR='ffmprovisr' AUTHOR='ffmprovisr'
RED='\033[1;31m' RED='\033[1;31m'
BLUE='\033[1;34m' BLUE='\033[1;34m'
NC='\033[0m' NC='\033[0m'
if [[ ${OSTYPE} = "cygwin" ]] || [ ! $(which diff) ]; then if [[ "${OSTYPE}" = "cygwin" ]] || [ ! $(which diff) ]; then
echo -e "${RED}Error: 'diff' is not installed by default. Please install 'diffutils' from Cygwin.${NC}" echo -e "${RED}Error: 'diff' is not installed by default. Please install 'diffutils' from Cygwin.${NC}"
exit 1 exit 1
fi fi
_output_prompt(){ _output_prompt(){
cat <<EOF cat <<EOF
Usage: ${SCRIPT} -h | -i <av_file> -m <md5_file> Usage: ${SCRIPT} -i <av_file> -m <md5_file> | -h
EOF EOF
exit 1 exit 1
} }
@ -21,13 +21,11 @@ EOF
_output_help(){ _output_help(){
cat <<EOF cat <<EOF
Syntax: Syntax:
${SCRIPT}
Prompts a short help message.
${SCRIPT} -h
This help.
${SCRIPT} -i <av_file> -m <md5_file> ${SCRIPT} -i <av_file> -m <md5_file>
Pass to the script the audio-visual file and the corresponding MD5 Pass to the script the audio-visual file and the corresponding MD5
file to check. file to check.
${SCRIPT} -h
This help.
Dependency: Dependency:
ffmpeg ffmpeg
About: About:
@ -40,11 +38,11 @@ EOF
unset input_file unset input_file
unset input_hash unset input_hash
while getopts ":hi:m:" opt; do while getopts ":i:m:h" opt; do
case "${opt}" in case "${opt}" in
i) input_file=${OPTARG} ;;
m) input_hash=${OPTARG} ;;
h) _output_help ;; h) _output_help ;;
i) input_file=$OPTARG ;;
m) input_hash=$OPTARG ;;
:) echo -e "${RED}Error: option -${OPTARG} requires an argument${NC}" ; _output_prompt ;; :) echo -e "${RED}Error: option -${OPTARG} requires an argument${NC}" ; _output_prompt ;;
*) echo -e "${RED}Error: bad option -${OPTARG}${NC}" ; _output_prompt ;; *) echo -e "${RED}Error: bad option -${OPTARG}${NC}" ; _output_prompt ;;
esac esac
@ -53,7 +51,7 @@ done
[[ -z "${#}" || ! ${input_file} || ! ${input_hash} ]] && _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
md5_tmp="${USERPROFILE}/$(basename "${input_hash}").tmp" md5_tmp="${USERPROFILE}/$(basename "${input_hash}").tmp"
else else
md5_tmp="${HOME}/$(basename "${input_hash}").tmp" md5_tmp="${HOME}/$(basename "${input_hash}").tmp"