Better support spaces in src filename
authorHugo Villeneuve <hugo@hugovil.com>
Tue, 10 Oct 2023 13:47:33 +0000 (09:47 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Tue, 10 Oct 2023 14:36:40 +0000 (10:36 -0400)
But still doesn't work because of the files arguments passed to the convert
command.

fgen.sh

diff --git a/fgen.sh b/fgen.sh
index 8a700c7..c7065c8 100755 (executable)
--- a/fgen.sh
+++ b/fgen.sh
@@ -230,20 +230,14 @@ if [ $# -eq 0 ]; then
     exit 1
 fi
 
-if [ $# -gt 1 ]; then
-    echo "${PROG_NAME}: Trop d'arguments."
-    echo "Essayez \`${PROG_NAME} -h' pour plus d'informations."
-    exit 1
-fi
+src="${*}"
 
-if [ ! -f "${1}" ]; then
+if [ ! -f "${src}" ]; then
     log_err "Error: PSD source file not found"
     exit 1
 fi
 
-src=${1}
-
-dest=$(basename -s .psd ${1})
+dest=$(basename -s .psd "${src}")
 layers=${dest}/layers.txt
 
 if [ ! -d ${dest} ]; then
@@ -259,7 +253,7 @@ done
 
 if [ ${trames} -eq 1 ]; then
     # %s: scene number
-    identify ${IM_OPS} -verbose -format "scene:%s,label:%l,geometry:%g,\n" ${src} > ${layers}
+    identify ${IM_OPS} -verbose -format "scene:%s,label:%l,geometry:%g,\n" "${src}" > ${layers}
 
     # Remove line(s) with empty label:
     ${SED} -i -e /label:,.*/d ${layers}