mirror of
https://github.com/tests-always-included/mo.git
synced 2024-12-18 16:27:52 +00:00
Must have IFS set properly
This lets the value returned from mustache-is-standalone get parsed correctly. When this is a standalone template, the value returned looks like "12 34" where each number is a position. Later, this is used in a line that looks like `( $VALUE_RETURNED )`. When IFS does not contain a space, this array is not built correctly.
This commit is contained in:
parent
e1b6815b8c
commit
70cc736b4a
12
mo
12
mo
@ -289,14 +289,14 @@ mustache-is-standalone() {
|
|||||||
|
|
||||||
if [[ "$CHAR" != $'\n' ]] && [[ "$CHAR" != $'\r' ]]; then
|
if [[ "$CHAR" != $'\n' ]] && [[ "$CHAR" != $'\r' ]]; then
|
||||||
if [[ ! -z "$CHAR" ]] || ! $4; then
|
if [[ ! -z "$CHAR" ]] || ! $4; then
|
||||||
return 1;
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CHAR=${AFTER_TRIMMED:0:1}
|
CHAR=${AFTER_TRIMMED:0:1}
|
||||||
|
|
||||||
if [[ "$CHAR" != $'\n' ]] && [[ "$CHAR" != $'\r' ]] && [[ ! -z "$CHAR" ]]; then
|
if [[ "$CHAR" != $'\n' ]] && [[ "$CHAR" != $'\r' ]] && [[ ! -z "$CHAR" ]]; then
|
||||||
return 2;
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$CHAR" == $'\r' ]] && [[ "${AFTER_TRIMMED:1:1}" == $'\n' ]]; then
|
if [[ "$CHAR" == $'\r' ]] && [[ "${AFTER_TRIMMED:1:1}" == $'\n' ]]; then
|
||||||
@ -722,5 +722,13 @@ mustache-trim-whitespace() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mo() (
|
||||||
|
# Execute in a subshell so IFS is reset
|
||||||
|
IFS=$' \n\t'
|
||||||
mustache-get-content MUSTACHE_CONTENT "$@"
|
mustache-get-content MUSTACHE_CONTENT "$@"
|
||||||
mustache-parse "$MUSTACHE_CONTENT" "" true
|
mustache-parse "$MUSTACHE_CONTENT" "" true
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ "$0" == "$BASH_SOURCE" ]] || ! [[ -n "$BASH_SOURCE" ]]; then
|
||||||
|
mo "$@"
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user