mirror of
https://github.com/tests-always-included/mo.git
synced 2025-11-19 23:34:32 +01:00
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:
@@ -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" ${@+"$@"}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>"
|
||||
}
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
<b> Willy is awesome.
|
||||
</b>... this is the last line.
|
||||
<b> Willy is awesome.</b>... this is the last line.
|
||||
|
||||
Reference in New Issue
Block a user