I think this finally implements arguments to functions

This closes #18.
This commit is contained in:
Tyler Akins
2017-11-03 16:34:08 -05:00
parent ab5dfee519
commit a5ec7dd740
4 changed files with 66 additions and 5 deletions

16
tests/function-args.env Normal file
View 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" "$@"
}

View 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

View 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}}