diff --git a/mo b/mo index cc66240..934c69b 100755 --- a/mo +++ b/mo @@ -110,7 +110,7 @@ mo() ( done fi - moGetContent moContent "${files[@]}" + moGetContent moContent "${files[@]}" || return 1 moParse "$moContent" "" true ) @@ -246,7 +246,7 @@ moGetContent() { content="$content"'{{>'"$filename"'}}' done else - moLoadFile content /dev/stdin + moLoadFile content /dev/stdin || return 1 fi local "$target" && moIndirect "$target" "$content" @@ -526,7 +526,7 @@ moLoadFile() { # As a future optimization, it would be worth considering removing # cat and replacing this with a read loop. - content=$(cat -- "$2"; echo '.') + content=$(cat -- "$2" && echo '.') || return 1 len=$((${#content} - 1)) content=${content:0:$len} # Remove last dot @@ -735,7 +735,7 @@ moPartial() { # but that's difficult when you're only given filenames. cd "$(dirname -- "$moFilename")" || exit 1 moUnindented="$( - moLoadFile moPartial "${moFilename##*/}" + moLoadFile moPartial "${moFilename##*/}" || exit 1 moParse "${moPartial}" "$6" true # Fix bash handling of subshells and keep trailing whitespace. diff --git a/tests/partial-missing.expected b/tests/partial-missing.expected new file mode 100644 index 0000000..83597d5 --- /dev/null +++ b/tests/partial-missing.expected @@ -0,0 +1 @@ +cat: partial-missing.partial: No such file or directory diff --git a/tests/partial-missing.sh b/tests/partial-missing.sh new file mode 100755 index 0000000..d06b174 --- /dev/null +++ b/tests/partial-missing.sh @@ -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 diff --git a/tests/partial-missing.template b/tests/partial-missing.template new file mode 100644 index 0000000..bbd3a9e --- /dev/null +++ b/tests/partial-missing.template @@ -0,0 +1 @@ +Won't be there: {{> partial-missing.partial}}