I have the following script that extracts data from the EXIF command on my busybox ash-based system. I parse the date tag from the end of the file and use case as a final check to ensure the format is correct. My problem is the if statement at the end always seems to return true; i.e. d="$e - Jebby (exif" always runs. If I echo $en and echo $dn it shows $en is greater than $dn but the if statement still runs the d="$e - Jebby (exif".
x=<valid filename>
e=$(exif -d -m -t 0x9003 -- "$x" 2>/dev/null)
let l=${#e}-18
e=$(expr substr "$e" $l 19)
e="${e%[ ][0-2][0-9][:][0-6][0-9][:][0-6][0-9]*}"
e="${e##*[!1-2][!09][!0-9][!0-9][!:][!0-1][!0-9][!:][!0-3][!0-9]}"
e=$(expr substr "$e" 1 4)$(expr substr "$e" 6 2)$(expr substr "$e" 9 2)
case "$e" in
[1-2][09][0-9][0-9][0-1][0-9][0-3][0-9])
let en=$e+3
ds="${d% - Jebby (}"
let dn=$ds
if [ $en -lt $dn ]; then
d="$e - Jebby (exif"
fi
esac