errlog()
{
- local lastexit=$?
+ local lastexit=1
local msg="$1"
echo "❌ ERROR: $msg"
main()
{
local file="$1"
+ local dir=
+ local out=
+ local include_files=
[ -n "$file" ] \
|| "missing file" \
|| 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 $?
echo "$out"
}
-main $*
\ No newline at end of file
+main "$*"
\ No newline at end of file