I have a bash function like the following:
foo() {
echo $1
}
or
bar() {
baz $1
}
If I then call foo 'file[1-3]' the result is file1 file2 file3, not file[1-3]. Analogous phenomenon happens when passing the parameter to a call of another bash function like in the function bar. What’s the easiest way around this besides ensuring that there are no matching files in the current directory so that I can reference the parameter when echoing or passing the parameter to another function?
EDIT: String matching doesn’t seem to expand the glob. My specific problem manifested when performing a string match in the internal call to another function. It was the call to the other function that appears to have expanded the pattern.
Insert this into the top of your script: