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.
This commit is contained in:
Tyler Akins
2017-11-13 10:13:03 -06:00
parent e78b15d95b
commit ad98577c42
7 changed files with 25 additions and 22 deletions

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.