So functions can take arguments in this scripting system? None of the tutorials I have found show examples of that. In that case I should really send the $@ as an argument to my function...Paeryn wrote: ↑Thu Apr 16, 2020 5:03 pmThe reason that $@ doesn't work for you when used in a function is because inside a function the positional variables $0 to $9, $@ and $# refer to the function's arguments rather than the script's.Bosse_B wrote: ↑Thu Apr 16, 2020 9:52 amThe last argument to the getopts call is optional and if missing getopts reverts to use the full command line arguments as given by $@.
But this seems not to work inside a function,
...
Seems like if inside a function it is unable to get the input arguments from the command line!
But reading these into a variable in mainline code and add that variable at the end of the call to getopts makes it work!
I will have to search for such examples now. Arguments to functions is what I use in all other languages instead of using globals (ouch!)...