7 Commits
1.1.0 ... 2.0.4

Author SHA1 Message Date
Tyler Akins
dbefade193 Adding a version number
It is shown with --help. It's also available as $MO_VERSION when mo is
sourced.
2017-11-30 05:43:10 -06:00
Tyler Akins
57a8d41394 Merge pull request #21 from jas99/patch-1
Fix: Intall issue
2017-11-20 07:22:43 -06:00
Jaspreet Singh
5739ccd705 Fix: Intall issue
Added -L flag to curl; so as to allow following redirect.
2017-11-19 15:53:12 +05:30
Tyler Akins
f889c37316 Found another issue with strict mode 2017-11-13 13:53:38 -06:00
Tyler Akins
4f615a0faf More fixes if variables are not set and strict mode is enabled 2017-11-13 10:43:32 -06:00
Tyler Akins
1e91e414cc Fix for when running in strict mode 2017-11-13 10:31:51 -06:00
Tyler Akins
ad98577c42 Changing how functions are called
Old way:

    functionName CONTENT argument1 argument2

New way:

    echo -n "$CONTENT" | functionName argument1 argument2

This follow the Unix style more closely.
2017-11-13 10:13:56 -06:00
8 changed files with 33 additions and 27 deletions

View File

@@ -41,7 +41,7 @@ There are a few ways you can install this tool. How you install it depends on h
You can install this file in `/usr/local/bin/` or `/usr/bin/` by simply downloading it, changing the permissions, then moving it to the right location. Double check that your system's PATH includes the destination folder, otherwise users may have a hard time starting the command.
# Download
curl -sS https://git.io/get-mo -o mo
curl -sSL https://git.io/get-mo -o mo
# Make executable
chmod +x mo

View File

@@ -3,6 +3,9 @@
cd "$(dirname "$0")" # Go to the script's directory
EVERY_REPO() {
# The block contents come in through standard input. Capture it here.
content=$(cat)
echo "# Starting EVERY_REPO"
# Get list of repos
@@ -14,7 +17,7 @@ EVERY_REPO() {
# It rewrites {{__REPO__.name}} into {{resque.name}}, for instance.
# You can prefix your environment variables and do other things as well.
echo -n "$1" | sed "s/__REPO__/${REPO}/"
echo "$content" | sed "s/__REPO__/${REPO}/"
echo "## Looped one time for repo: $REPO"
done

View File

@@ -2,13 +2,17 @@
cd "$(dirname "$0")"/..
date-string() { date; }
wrapper() { echo -n "*** $1 ***"; }
date-string() {
date
}
wrapper() {
echo -n "*** $(cat) ***"
}
export IP=127.0.0.1
export ALLOWED_HOSTS=( 192.168.0.1 192.168.0.2 192.168.0.3 )
. mo # Keep in mind this script is executing in the parent directory
. ./mo # Keep in mind this script is executing in the parent directory
cat <<EOF | mo
# {{#wrapper}}OH SO IMPORTANT{{/wrapper}}
# This file automatically generated at {{date-string}}

22
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,11 +1030,14 @@ 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.

View File

@@ -2,16 +2,12 @@ name=Willy
MO_ALLOW_FUNCTION_ARGUMENTS=true
pipeTo() {
echo -n "$1" | "$2"
cat | "$1"
}
testArgs() {
printf "%d" "$#"
# Remove content. Note that when zero arguments are passed, this
# line does nothing and $1 will still be the content.
shift
# Display all arguments
printf " %q" "$@"
printf " %q" ${@+"$@"}
}

View File

@@ -1,4 +1,4 @@
No args: 1 '' - done
One arg: 2 one - done
Getting name in a string: 2 The\ name\ is\ Willy - done
No args: 0 '' - done
One arg: 1 one - done
Getting name in a string: 1 The\ name\ is\ Willy - done
Reverse this: edcba

View File

@@ -1,5 +1,5 @@
name=Willy
wrapped() {
# The final newline is eaten by mo
echo "<b>$1</b>"
# This eats the newline in the content
echo "<b>$(cat)</b>"
}

View File

@@ -1,2 +1 @@
<b> Willy is awesome.
</b>... this is the last line.
<b> Willy is awesome.</b>... this is the last line.