From 5b8cf240687816a81d948bcb9e32f6077f74f10d Mon Sep 17 00:00:00 2001 From: Andrea Bonomi Date: Thu, 8 Aug 2019 10:36:44 +0200 Subject: [PATCH] Pass arguments to function as environment variable MO_ALLOW_FUNCTION_ARGUMENTS --- demo/function-args | 29 +++++++++++++++++++++++++++++ demo/function-args-part1 | 1 + demo/function-args-part2 | 3 +++ mo | 14 +++++++------- tests/function-args-read.env | 2 +- 5 files changed, 41 insertions(+), 8 deletions(-) create mode 100755 demo/function-args create mode 100644 demo/function-args-part1 create mode 100644 demo/function-args-part2 diff --git a/demo/function-args b/demo/function-args new file mode 100755 index 0000000..83fa354 --- /dev/null +++ b/demo/function-args @@ -0,0 +1,29 @@ +#!/bin/bash +# +# This sources a simple script with the env. variables needed for the template. + +cd "$(dirname "$0")" # Go to the script's directory +source ../mo + +export NAME="Alex" +export ARRAY=( AAA BBB CCC ) + +# Include an external template +INCLUDE() { + cat "$MO_FUNCTION_ARGS" +} + +# Print section title +TITLE() { + echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" + echo "$MO_FUNCTION_ARGS" + echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" +} + +cat <