From 417b1adc55322e0aa625f5953e269ab6a9b6367f Mon Sep 17 00:00:00 2001 From: q3aql Date: Tue, 23 Mar 2021 17:49:13 +0100 Subject: [PATCH] Improved error handling (ks-crop) --- src/ks-crop | 58 +++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/src/ks-crop b/src/ks-crop index a46ce5c..d18b550 100755 --- a/src/ks-crop +++ b/src/ks-crop @@ -116,6 +116,17 @@ function show_menu() { exit } +# Function to show error reading file +# Syntax: errorReadingFile +function errorReadingFile() { + echo "" + echo "* ks-crop (ks-tools) v${VERSION} (${M_DATE})" + echo "" + echo "* The file '${1}' does not exist!" + echo "" + exit +} + # Conversion parameters p_ffmpeg="ffmpeg -i" p_ffmpeg_patched="-max_muxing_queue_size 9999" @@ -149,6 +160,11 @@ elif [ "${1}" == "-5:4-aspect" ] ; then else show_menu fi +if [ -f "${2}" ] ; then + echo "detected" > /dev/null +else + errorReadingFile "${2}" +fi # Detect resolution of video file detect_2=$(ffmpeg -i ${2} 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 2 | cut -d "[" -f 1 | tr -s " " | grep x) @@ -664,51 +680,13 @@ function crop_video() { # Syntax: ks-crop