I have a Bash script which passes patterns and switches to grep.
#!/bin/bash
foo() {
grep $@ *.txt
}
foo $@
And, of course, myscript SomeText works but myscript "Text1 Text2" does not. Is there a way to keep the quotes when passing arguments from script to foo() and then from foo() to grep?
Note, that I cannot simply use eval and wrap the whole $@ before grep since it can also contain switches so I need to keep the original quoting as passed from the command line.
Thanks.