mirror of
https://github.com/tests-always-included/mo.git
synced 2025-11-19 23:34:32 +01:00
I think this finally implements arguments to functions
This closes #18.
This commit is contained in:
16
tests/function-args.env
Normal file
16
tests/function-args.env
Normal file
@@ -0,0 +1,16 @@
|
||||
name=Willy
|
||||
|
||||
pipeTo() {
|
||||
echo -n "$1" | "$2"
|
||||
}
|
||||
|
||||
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" "$@"
|
||||
}
|
||||
4
tests/function-args.expected
Normal file
4
tests/function-args.expected
Normal file
@@ -0,0 +1,4 @@
|
||||
No args: 1 '' - done
|
||||
One arg: 2 one - done
|
||||
Getting name in a string: 2 The\ name\ is\ Willy - done
|
||||
Reverse this: edcba
|
||||
4
tests/function-args.template
Normal file
4
tests/function-args.template
Normal file
@@ -0,0 +1,4 @@
|
||||
No args: {{testArgs}} - done
|
||||
One arg: {{testArgs one}} - done
|
||||
Getting name in a string: {{testArgs "The name is $name"}} - done
|
||||
Reverse this: {{#pipeTo rev}}abcde{{/pipeTo}}
|
||||
Reference in New Issue
Block a user