I'm playing around with a simpler way to make animated GIFs with captions using gifify (forked from jclem) using ffmpeg and it's captioning library. I tried adding a variable to my script, looking for the optional argument, but I can't even get it to create the temporary .srt file necessary.
Here's my script creating a .txt as proof of concept:
#!/bin/bash
while getopts "t" opt; do
case opt in
t) text=$OPTARG;;
esac
done
shift $(( OPTIND - 1 ))
subtitles=$1
#If there is text present, do this
if [ -z ${text} ]; then
#Make an empty txt file
cat >> /tmp/subs.txt
text=$subtitles
append ${text}
fi
I then run it with:
sh text.sh -t "This is my text"
The script runs and will echo out the string of text you put into the shell, but it won't add it to the new file. Any thoughts on what I'm doing wrong?
appenddo in bash?catline. That should becat /dev/null > /tmp/subs.txt.$textis empty. What does it do when you supply this argument, as in the example?[ -z $variable ]is an unsafe test. If$variableis empty that test will still pass because the shell will end up seeing[ -z ]which[will then interpret as[ -n -z ]and pass as-zis non-empty. The test needs to be[ -z "$variable" ]to force an empty variable to be an empty string..srtfile. So it isn't surprising that one isn't created.