The quotes are removed before the arguments are passed to your script, so it's too late to save them. What you can do is to preserve their effect when passing arguments to the internal command and restore the equivalent quoted / escaped version of the arguments for printing. A.
To pass arguments to the internal command "$@" - with double quotes, $ @ saves the original word breaks, which means that the internal command receives exactly the same list of arguments as your script.
For printing, you can use the% q format in the bash printf command to restore citation. Please note that this will not always lead to the restoration of the original quotation, but will build an equivalent quote / escaped string. For example, if you passed the argument 'uptime ; uname -a' 'uptime ; uname -a' , it can print uptime\ \;\ uname\ -a or "uptime ; uname -a" or any other equivalent (see @William Pursell's answer for similar examples).
Here is an example of their use:
printf "Running command:" printf " %q" innercmd "$@"
Gordon Davisson May 31 '12 at 15:05 2012-05-31 15:05
source share