Fix exit code when partial file not found

This commit is contained in:
Alexey Maslennikov 2017-06-23 21:10:38 +02:00
parent 6376a9b817
commit 078dcabb06
4 changed files with 14 additions and 4 deletions

8
mo
View File

@ -110,7 +110,7 @@ mo() (
done done
fi fi
moGetContent moContent "${files[@]}" moGetContent moContent "${files[@]}" || return 1
moParse "$moContent" "" true moParse "$moContent" "" true
) )
@ -246,7 +246,7 @@ moGetContent() {
content="$content"'{{>'"$filename"'}}' content="$content"'{{>'"$filename"'}}'
done done
else else
moLoadFile content /dev/stdin moLoadFile content /dev/stdin || return 1
fi fi
local "$target" && moIndirect "$target" "$content" local "$target" && moIndirect "$target" "$content"
@ -526,7 +526,7 @@ moLoadFile() {
# As a future optimization, it would be worth considering removing # As a future optimization, it would be worth considering removing
# cat and replacing this with a read loop. # cat and replacing this with a read loop.
content=$(cat -- "$2"; echo '.') content=$(cat -- "$2" && echo '.') || return 1
len=$((${#content} - 1)) len=$((${#content} - 1))
content=${content:0:$len} # Remove last dot content=${content:0:$len} # Remove last dot
@ -735,7 +735,7 @@ moPartial() {
# but that's difficult when you're only given filenames. # but that's difficult when you're only given filenames.
cd "$(dirname -- "$moFilename")" || exit 1 cd "$(dirname -- "$moFilename")" || exit 1
moUnindented="$( moUnindented="$(
moLoadFile moPartial "${moFilename##*/}" moLoadFile moPartial "${moFilename##*/}" || exit 1
moParse "${moPartial}" "$6" true moParse "${moPartial}" "$6" true
# Fix bash handling of subshells and keep trailing whitespace. # Fix bash handling of subshells and keep trailing whitespace.

View File

@ -0,0 +1 @@
cat: partial-missing.partial: No such file or directory

8
tests/partial-missing.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
cd "${0%/*}"
../mo partial-missing.template 2>&1
if [[ $? -ne 1 ]]; then
echo "Did not return 1"
fi

View File

@ -0,0 +1 @@
Won't be there: {{> partial-missing.partial}}