Python: TCC command line parsing removes '=' equal sign characters

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Nov 8, 2012
3
0
#1
When I use an equals signs in a command line parameter to a python script it use the equal sign as white space.

#test.py
import sys

print("arg count=%u" %len(sys.argv))
print("sys.argv[0]=%s" %sys.argv[0])
print("sys.argv[1]=%s" %sys.argv[1])
if len(sys.argv) >= 3:
print("sys.argv[2]=%s" %sys.argv[2])
else:
print("no value in sys.argv[2]")


The output results for CMD and TCC 13 or 14.

[c:\]ver

TCC LE 13.04.63 Windows 7 [Version 6.1.7601]

[c:\]python e:\temp\test.py --path=c:\temp
arg count=3
sys.argv[0]=e:\temp\test.py
sys.argv[1]=--path
sys.argv[2]=c:\temp

[c:\]cmd
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

c:\>python e:\temp\test.py --path=c:\temp
arg count=2
sys.argv[0]=e:\temp\test.py
sys.argv[1]=--path=c:\temp
no value in sys.argv[2]


This makes writing command line parsing very difficult.
Can I report this as a bug?

J.R. Heisey
 
#2
I don't know if it's a bug or not, but you might get around it by escaping the "=".
Code:
python e:\temp\test.py --path^=c:\temp
or, if python can deal with it, quote the second arg.
Code:
python e:\temp\test.py "--path=c:\temp"
Not having python, I can't test it.
 
Nov 8, 2012
3
0
#5
CMDBatchDelimiters=no has corrected the issue even on LE. Thanks Charles.
The Python script is invoked by a make based software build system used by a hundred developers so I cannot change parameters. I am the only one who uses TCC.
  1. I could not find any documentation on this in the help file when using the keyword search for 'equal sign parameter delimiter'. OK now that I know what to look for the keywords 'argument delimiter' does show this topic.
  2. Searching for CMDBatchDelimiters does find the topic. I see the statement (Note: this will break CMD compatibility!) when set to 'no' which is not my experience on Windows 7 64 bit.
  3. The name CMDBatchDelimiters is confusing.
I would have expected something like EqualSignAsCommandLineDelimiter
I used to have paid licenses starting with 4DOS then 4NT for a while.
Now that was a long time ago. ;)