Message5692

Author pekka.klarck
Recipients pekka.klarck
Date 2010-04-13.14:14:52
SpamBayes Score 1.761924e-13
Marked as misclassified No
Message-id <1271168093.68.0.595355515536.issue1594@psf.upfronthosting.co.za>
In-reply-to
Content
I investigated the jython.bat script and it seems that the following helper causes the problem:

:getArg
rem remove quotes around first arg
for %%i in (%1) do set _CMP=%%~i
set _ARGS=%2
goto :EOF

When this helper gets e.g. *.txt or *.none in as %1, the pattern is expanded when it's used in `for %%i in (%1)`. If the pattern matches something, _CMP will get the last value, and when there's no match _CMP is not set at all. Not setting _CMP leads that later in :procArg arguments are erased.

I don't see any reason for the for loop in the above helper. If it is changed to just `set _CMP=%~1`, patterns aren't expanded but the helper seems to work otherwise as it should. This is what I get when executing a fixed version of the script:

C:\path>jython-fix  -c "import sys; print sys.argv[1:]" x\*.txt
['x\\f1.txt', 'x\\f2.txt']
C:\path>jython-fix  -c "import sys; print sys.argv[1:]" *.none second
['*.none', 'second']

Notice that when the pattern matches the results are different to what you got with CPython where you always get the string as-is. At least I'm fine with it because that's the effective behavior on Unixes where the shell expands patterns and that's also how Jython 2.2 behaves.

DISCLAIMER: My batch file coding skills aren't good enough to tell could the change I propose break something else. It would be great to hear a second opinion from someone who has been unfortunate to play more with batch files, preferably from someone who also knows the jython.bat file well.
History
Date User Action Args
2010-04-13 14:14:53pekka.klarcksetmessageid: <1271168093.68.0.595355515536.issue1594@psf.upfronthosting.co.za>
2010-04-13 14:14:53pekka.klarcksetrecipients: + pekka.klarck
2010-04-13 14:14:53pekka.klarcklinkissue1594 messages
2010-04-13 14:14:52pekka.klarckcreate