I have a bash script where I'm trying to pass posix style arguments with quoted values down to another script called within. On the command-line I might type:
somescript --foo="bar baz"
This means with the argument having the key foo
, the value is bar baz
. Within somescript, you might think this would work:
innerscript "$@"
However, this re-quotes the entirety of each argument, both key and value chunked together, not just the value. So innerscript receives "--foo=bar baz"
and believes you are trying to pass the key named foo=bar baz
with an empty value.
It's not good enough to tell bash "re-quote all the passed in arguments". I need to tell bash "re-quote all passed in arguments exactly how they were quoted before". Don't change the position of my quotes, bro!