Updates for how to source "mo" and then use it

When you source mo, it adds the "mo" function to the environment.
This commit is contained in:
Tyler Akins
2015-08-27 09:44:04 -05:00
parent e623b16bb8
commit b16d73b5a7
8 changed files with 18 additions and 9 deletions

View File

@@ -4,8 +4,9 @@ cd "$(dirname "$0")" # Go to the script's directory
declare -A DATA
DATA=([one]=111 [two]=222)
. ../mo
cat <<EOF | . ../mo
cat <<EOF | mo
Accessing data directly:
DATA: {{DATA}}
One: {{DATA.one}}

View File

@@ -11,7 +11,8 @@ export OPTIONS=(
"Call a service representative at 1-800-000-0000 to discuss payment options"
"Return the vehicle immediately and pay a fine of 1 million dollars"
)
sed '0,/^# END/ d' "$(basename "$0")" | . ../mo
. ../mo
sed '0,/^# END/ d' "$(basename "$0")" | mo
exit
# END

View File

@@ -28,8 +28,8 @@ declare -A resque hub rip
resque=([name]=Resque [url]=http://example.com/resque)
hub=([name]=Hub [url]=http://example.com/hub)
rip=([name]=Rip [url]=http://example.com/rip)
cat <<EOF | . ../mo
. ../mo
cat <<EOF | mo
{{#EVERY_REPO}}
The repo is __REPO__
Name: {{__REPO__.name}}

View File

@@ -8,7 +8,8 @@ wrapper() { echo -n "*** $1 ***"; }
export IP=127.0.0.1
export ALLOWED_HOSTS=( 192.168.0.1 192.168.0.2 192.168.0.3 )
cat <<EOF | . mo
. 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}}
home_ip={{IP}}

View File

@@ -1,7 +1,8 @@
#!/bin/bash
cd "$(dirname "$0")" # Go to the script's directory
export ARRAY=( one two "three three three" four five )
cat << EOF | . ../mo
. ../mo
cat << EOF | mo
Here are the items in the array:
{{#ARRAY}}
* {{.}}

View File

@@ -1,4 +1,7 @@
#!/bin/bash
#
# This example does not source `mo` and is intentionally restricted to
# variables that are not arrays.
cd "$(dirname "$0")" # Go to the script's directory
export TEST="This is a test"
echo "Your message: {{TEST}}" | ../mo