mirror of
https://github.com/tests-always-included/mo.git
synced 2024-12-18 16:27:52 +00:00
Updates for style and to fix exit on error in some contexts
This commit is contained in:
parent
17f0e4be3d
commit
410883c85d
29
mo
29
mo
@ -150,7 +150,7 @@ moFindEndTag() {
|
|||||||
|
|
||||||
if [[ "$tag" == "$3" ]]; then
|
if [[ "$tag" == "$3" ]]; then
|
||||||
#: Found our end tag
|
#: Found our end tag
|
||||||
if [[ -z "$4" ]] && moIsStandalone standaloneBytes "$scanned" "${content[2]}" true; then
|
if [[ -z "${4-}" ]] && moIsStandalone standaloneBytes "$scanned" "${content[2]}" true; then
|
||||||
#: This is also a standalone tag - clean up whitespace
|
#: This is also a standalone tag - clean up whitespace
|
||||||
#: and move those whitespace bytes to the "tag" element
|
#: and move those whitespace bytes to the "tag" element
|
||||||
standaloneBytes=( $standaloneBytes )
|
standaloneBytes=( $standaloneBytes )
|
||||||
@ -208,7 +208,7 @@ moFindString() {
|
|||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
moFullTagName() {
|
moFullTagName() {
|
||||||
if [[ -z "$2" ]] || [[ "$2" == *.* ]]; then
|
if [[ -z "${2-}" ]] || [[ "$2" == *.* ]]; then
|
||||||
local "$1" && moIndirect "$1" "$3"
|
local "$1" && moIndirect "$1" "$3"
|
||||||
else
|
else
|
||||||
local "$1" && moIndirect "$1" "${2}.${3}"
|
local "$1" && moIndirect "$1" "${2}.${3}"
|
||||||
@ -260,8 +260,9 @@ moIndentLines() {
|
|||||||
#: This removes newline and dot from the workaround in moPartial
|
#: This removes newline and dot from the workaround in moPartial
|
||||||
content="${3:0:$len}"
|
content="${3:0:$len}"
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
if [[ -z "${2-}" ]]; then
|
||||||
local "$1" && moIndirect "$1" "$content"
|
local "$1" && moIndirect "$1" "$content"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -279,7 +280,7 @@ moIndentLines() {
|
|||||||
|
|
||||||
moTrimChars trimmed "$fragment" false true " " $'\t' $'\n' $'\r'
|
moTrimChars trimmed "$fragment" false true " " $'\t' $'\n' $'\r'
|
||||||
|
|
||||||
if [ ! -z "$trimmed" ]; then
|
if [[ -n "$trimmed" ]]; then
|
||||||
fragment="$2$fragment"
|
fragment="$2$fragment"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -290,7 +291,7 @@ moIndentLines() {
|
|||||||
|
|
||||||
moTrimChars trimmed "$content" false true " " $'\t'
|
moTrimChars trimmed "$content" false true " " $'\t'
|
||||||
|
|
||||||
if [ ! -z "$trimmed" ]; then
|
if [[ -n "$trimmed" ]]; then
|
||||||
content="$2$content"
|
content="$2$content"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -346,6 +347,10 @@ moIndirectArray() {
|
|||||||
#
|
#
|
||||||
# $1 - Name of environment variable
|
# $1 - Name of environment variable
|
||||||
#
|
#
|
||||||
|
# Be extremely careful. Even if strict mode is enabled, it is not honored
|
||||||
|
# in newer versions of Bash. Any errors that crop up here will not be
|
||||||
|
# caught automatically.
|
||||||
|
#
|
||||||
# Examples
|
# Examples
|
||||||
#
|
#
|
||||||
# var=(abc)
|
# var=(abc)
|
||||||
@ -371,6 +376,10 @@ moIsArray() {
|
|||||||
#
|
#
|
||||||
# $1 - Function name to check
|
# $1 - Function name to check
|
||||||
#
|
#
|
||||||
|
# Be extremely careful. Even if strict mode is enabled, it is not honored
|
||||||
|
# in newer versions of Bash. Any errors that crop up here will not be
|
||||||
|
# caught automatically.
|
||||||
|
#
|
||||||
# Examples
|
# Examples
|
||||||
#
|
#
|
||||||
# moo () {
|
# moo () {
|
||||||
@ -426,14 +435,14 @@ moIsStandalone() {
|
|||||||
char=${beforeTrimmed:$char}
|
char=${beforeTrimmed:$char}
|
||||||
|
|
||||||
if [[ "$char" != $'\n' ]] && [[ "$char" != $'\r' ]]; then
|
if [[ "$char" != $'\n' ]] && [[ "$char" != $'\r' ]]; then
|
||||||
if [[ ! -z "$char" ]] || ! $4; then
|
if [[ -n "$char" ]] || ! $4; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
char=${afterTrimmed:0:1}
|
char=${afterTrimmed:0:1}
|
||||||
|
|
||||||
if [[ "$char" != $'\n' ]] && [[ "$char" != $'\r' ]] && [[ ! -z "$char" ]]; then
|
if [[ "$char" != $'\n' ]] && [[ "$char" != $'\r' ]] && [[ -n "$char" ]]; then
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -744,7 +753,7 @@ moSplit() {
|
|||||||
result[1]=${result[0]:$pos + ${#3}}
|
result[1]=${result[0]:$pos + ${#3}}
|
||||||
result[0]=${result[0]:0:$pos}
|
result[0]=${result[0]:0:$pos}
|
||||||
|
|
||||||
if [[ ! -z "$4" ]]; then
|
if [[ -n "${4-}" ]]; then
|
||||||
moFindString pos "${result[1]}" "$4"
|
moFindString pos "${result[1]}" "$4"
|
||||||
|
|
||||||
if [[ "$pos" -ne -1 ]]; then
|
if [[ "$pos" -ne -1 ]]; then
|
||||||
@ -824,10 +833,10 @@ moTest() {
|
|||||||
# If MO_FALSE_IS_EMPTY is set, then return 1 if the value of
|
# If MO_FALSE_IS_EMPTY is set, then return 1 if the value of
|
||||||
# the variable is "false".
|
# the variable is "false".
|
||||||
# shellcheck disable=SC2031
|
# shellcheck disable=SC2031
|
||||||
[[ ! -z "${MO_FALSE_IS_EMPTY-}" ]] && [[ "${!1-}" == "false" ]] && return 1
|
[[ -n "${MO_FALSE_IS_EMPTY-}" ]] && [[ "${!1-}" == "false" ]] && return 1
|
||||||
|
|
||||||
# Environment variables must not be empty
|
# Environment variables must not be empty
|
||||||
[[ ! -z "${!1}" ]] && return 0
|
[[ -n "${!1}" ]] && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
Loading…
Reference in New Issue
Block a user