]> gitweb.hhaalo.de Git - scantopdf.git/commitdiff
fix include shellcheck issues
authorBastian Dehn <hhaalo@arcor.de>
Sun, 28 Jun 2026 09:19:01 +0000 (11:19 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 28 Jun 2026 09:19:01 +0000 (11:19 +0200)
tools/includer

index 2dba97336d0996cef41b815b4df2b3569c0b3f8f..7d80311a26b2b1f96b1977e40f2392544df16567 100755 (executable)
@@ -2,7 +2,7 @@
 
 errlog()
 {
-       local lastexit=$?
+       local lastexit=1
        local msg="$1"
 
        echo "❌ ERROR: $msg"
@@ -13,6 +13,9 @@ errlog()
 main()
 {
        local file="$1"
+       local dir=
+       local out=
+       local include_files=
 
        [ -n "$file" ] \
                || "missing file" \
@@ -21,18 +24,17 @@ main()
                || errlog "file $file does not exists" \
                || return $?
 
-       local dir=$(dirname "$file")
+       dir=$(dirname "$file")
        local regex="^#include \"\(.*\)\"$"
 
-       local include_files=$(cat "$file" \
-               | grep --only-matching "$regex" \
+       include_files=$(grep --only-matching "$regex" "$file" \
                | sed "s/$regex/\1/")
 
        local include_file=
        local include_regex=
-       local out=$(cat $file)
+       out=$(cat "$file")
        for include_file in $include_files; do
-               [ -f $dir/$include_file ] \
+               [ -f "$dir/$include_file" ] \
                        || errlog "file $include_file does not exists" \
                        || return $?
 
@@ -45,4 +47,4 @@ main()
        echo "$out"
 }
 
-main $*
\ No newline at end of file
+main "$*"
\ No newline at end of file