In a bash script file, is there a way that I can use command line arguments from within a function which has parameters?
Or do I need to assign all command line parameters to a variable for them to be accessible in the function body?
echo $1 # may be "abc"
function f() { $1; } # will be "def", but I need "abc" here
f "def"
PS: I found a similar question on stack overflow, but that question doesn't deal with the issue I describe here?
f "$1"$1,$@and$*are overridden in the function by the function's context. You could create an array outside the function containing the command-line arguments –args=("$@")— and reference that within the function.