On 03/21/2012 08:24 AM, Andreas Marschke wrote: > Dear Maintainers of bash, > > it has come to my attention that bash is unexpectedly removing quotes > from parameters given to a script if read from within the > script. See attached shell-script for a full explanation. >
> # This does not constitute that quotations in the passed parameters are to be > ignored/removed upon > # passing them back to the script. Quotations are removed _before_ setting the positional parameters. If you want the positional parameters to contain quotes, you have to quote those quotes. > # > # Execute the following script like this: > # $> bash ./test.sh hello' ''dadewq'da''q That says to execute test.sh with one argument, whose contents are exactly: hello dadewqdaq > # > # The output should be something equal to: > # hello dadewqdaq > # > # As a user I would expect an output like: > # hello' ''dadewq'da''q Well, then you need to first pass that argument to the script, as in: bash ./test.sh "hello' ''dadewq'da''q" Notice how I quoted the ' characters by surrounding the overall argument in "". > # > # This is non-standard/unexpected behaviour. > > echo $@ Bug in your script - you generally want to use "$@", not $@, as the former replays the positional parameters exactly, while the latter is subject to globbing and field splitting which can alter the results based on what is currently in the positional parameters. -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature