I'm attempting to write a function in bash that will access the scripts command line arguments, but they are replaced with the positional arguments to the function. Is there any way for the function to access the command line arguments if they aren't passed in explicitly?
# Demo function
function stuff {
echo $0 $*
}
# Echo's the name of the script, but no command line arguments
stuff
# Echo's everything I want, but trying to avoid
stuff $*
$*
is extremely buggy -- it'll change./yourScript "first argument" "second argument"
to./yourscript "first" "argument" "second" "argument"
, or change./yourscript '*.txt'
to something like./yourscript one.txt two.txt
despite the quotes. – Application