This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients ezio.melotti, pitrou, r.david.murray, telmich
Date 2013-10-29.12:17:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1383049024.32.0.770047348979.issue19430@psf.upfronthosting.co.za>
In-reply-to
Content
Indeed, you can see in the original posting that the \ is already gone from the dollar in sys.argv, so argparse has nothing to do with it.

And it is indeed the shell doing the unescaping:

rdmurray@session:~>cat test.sh
#!/bin/bash
echo "$@"
rdmurray@session:~>bash test.sh "abc [\t] \$"
abc [\t] $
rdmurray@session:~>bash test.sh 'abc [\t] \$'
abc [\t] \$
rdmurray@session:~>bash test.sh 'abc [\t] \$'
abc [\t] \$
rdmurray@session:~>bash test.sh "'abc [\t] \$'"
'abc [\t] $'
rdmurray@session:~>bash test.sh "'abc [\t] \\$'"
'abc [\t] \$'
rdmurray@session:~>bash test.sh "'abc [\t] \\$foo'"
'abc [\t] \'
rdmurray@session:~>bash test.sh '"abc [\t] \\\$foo"'
"abc [\t] \\\$foo"
rdmurray@session:~>bash test.sh '"abc [\t] \$foo"'  
"abc [\t] \$foo"

The shell treats $ specially because $ has a special meaning inside double quotes (variable substitution), so it presumably unescapes it as part of the double quote string processing.  You have to escape both the backslash and the $ if you want a literal '\$' to wind up in argv, when the outer level of quoting is double quotes.
History
Date User Action Args
2013-10-29 12:17:04r.david.murraysetrecipients: + r.david.murray, pitrou, ezio.melotti, telmich
2013-10-29 12:17:04r.david.murraysetmessageid: <1383049024.32.0.770047348979.issue19430@psf.upfronthosting.co.za>
2013-10-29 12:17:04r.david.murraylinkissue19430 messages
2013-10-29 12:17:04r.david.murraycreate