updated stuff

This commit is contained in:
Nikolas Weger 2018-10-05 16:20:39 +02:00
parent c0c570fcd9
commit 00fec9b61b
13 changed files with 1484 additions and 345 deletions

23
bin/mo
View file

@ -141,15 +141,16 @@ mo() (
#
# Returns nothing.
moCallFunction() {
local moCommand
local moArgs
moArgs=()
# shellcheck disable=SC2031
if [[ -n "$MO_ALLOW_FUNCTION_ARGUMENTS" ]]; then
printf -v moCommand "%q %q %s" "$1" "$2" "$3"
eval "$moCommand"
else
"$1" "$2"
if [[ -n "${MO_ALLOW_FUNCTION_ARGUMENTS-}" ]]; then
moArgs=$3
fi
echo -n "$2" | eval "$1" "$moArgs"
}
@ -834,15 +835,15 @@ moShow() {
moSplit moNameParts "$1" "."
if [[ -z "${moNameParts[1]}" ]]; then
if [[ -z "${moNameParts[1]-}" ]]; then
if moIsArray "$1"; then
eval moJoin moJoined "," "\${$1[@]}"
echo -n "$moJoined"
else
# shellcheck disable=SC2031
if [[ -z "$MO_FAIL_ON_UNSET" ]] || moTestVarSet "$1"; then
if moTestVarSet "$1"; then
echo -n "${!1}"
else
elif [[ -n "${MO_FAIL_ON_UNSET-}" ]]; then
echo "Env variable not set: $1" >&2
exit 1
fi
@ -1029,15 +1030,17 @@ moTrimWhitespace() {
# Returns nothing.
moUsage() {
grep '^#/' "${MO_ORIGINAL_COMMAND}" | cut -c 4-
echo ""
set | grep ^MO_VERSION=
}
# Save the original command's path for usage later
MO_ORIGINAL_COMMAND="$(cd "${BASH_SOURCE[0]%/*}" || exit 1; pwd)/${BASH_SOURCE[0]##*/}"
MO_VERSION="2.0.4"
# If sourced, load all functions.
# If executed, perform the actions as expected.
if [[ "$0" == "${BASH_SOURCE[0]}" ]] || [[ -z "${BASH_SOURCE[0]}" ]]; then
mo "$@"
fi