#Make arguments global to the script.
Whilst this is a solution I would consider it a step in possibly the wrong direction. What NA and I tried to point out is that a function receives parameters exactly the same way your script does.
What this means is:
1. for a script:
Here we have the first parameter with a value of "tada" and it can be referenced in the script
(notice underline) using $1
2. for a function:
If you test the above function in a script, which may or may not be called with any parameters, the first call to the function 'foo' will yield a blank line as no parameter was passed to the function
however, the second call will echo the string "bar" on its own line as it is the first parameter passed to the function
If you then put it all together, ie. point one and two, and call the script in part two like so:
The code output will be:
< this is a blank line
Notice the first line is blank ( I had to add the additional information after < as the formatting didn't show the line ) and there is no mention at all of the string "tada".