aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmake-gif33
1 files changed, 19 insertions, 14 deletions
diff --git a/make-gif b/make-gif
index 320a4a0..2c33718 100755
--- a/make-gif
+++ b/make-gif
@@ -17,8 +17,7 @@ usage() {
echo " length in seconds -t <num> full length"
echo " gif fps -f <num> 10"
echo " gif pixel width -w <num> 480"
- echo " use subtitles -b"
- echo " use subtitle track -n <int> 0"
+ echo " use subtitle track -b <int> none"
[[ $hasgsic ]] && echo "optimise with gifsicle -g"
echo " print this help -h"
exit 1
@@ -28,8 +27,10 @@ usage() {
local tmp_pref
rm_tmps() {
- rm -f ${tmp_pref}-palette.png
- rm -f ${tmp_pref}-in
+ if [[ ${tmp_pref} ]]; then
+ rm -f ${tmp_pref}-palette.png
+ rm -f ${tmp_pref}-in
+ fi
}
abort() {
@@ -38,6 +39,8 @@ abort() {
exit 1
}
+trap 'abort' SIGABRT SIGHUP SIGINT SIGQUIT SIGTERM
+
local start="00:00:00"
local length=""
local fps=10
@@ -79,11 +82,11 @@ if [[ $hasgsic ]]; then
&& usage "width must be a positive integer"
width=$OPTARG
;;
- b) subs=true ;;
- n)
+ b)
[[ ! $(echo $OPTARG | grep -oE "$zintpat") ]] \
&& usage "sub track index must be a non-negative integer"
strack=$OPTARG
+ subs=true
;;
g) gsic=true ;;
h) usage ;;
@@ -114,11 +117,11 @@ else
&& usage "width must be a positive integer"
width=$OPTARG
;;
- b) subs=true ;;
- n)
+ b)
[[ ! $(echo $OPTARG | grep -oE "$zintpat") ]] \
&& usage "sub track index must be a non-negative integer"
strack=$OPTARG
+ subs=true
;;
h) usage ;;
[?]) usage "unrecognised option" ;;
@@ -137,15 +140,17 @@ shift $OPTIND-1
[[ "$1" != "%d.png" ]] && [[ ! -f "$1" ]] && usage "input file not found"
# make links
-tmp_pref="make-gif"
-tmp_pref="${2:h}/$tmp_pref"
-
-echo $tmp_pref
+local tmp_pref_i
+tmp_pref_i="make-gif"
+tmp_pref_i="${2:h}/${tmp_pref_i}"
-while [[ -f "${tmp_pref}-palette.png" ]] || [[ -f "${tmp_pref}-in" ]]; do
- tmp_pref="${tmp_pref}-1"
+while [[ -f "${tmp_pref_i}-palette.png" ]] || [[ -f "${tmp_pref_i}-in" ]]; do
+ tmp_pref_i="${tmp_pref_i}-1"
done
+tmp_pref="${tmp_pref_i}"
+
+
ln -s "${1:a}" "${tmp_pref}-in" \
|| abort "could not write to output dir"