Title: jython.bat corrupts command line arguments containing special characters
Type: Severity: normal
Components: Versions:
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: otmarhumbel Nosy List: fwierzbicki, geoffbache, otmarhumbel, pekka.klarck, zyasoft
Priority: Keywords:

Created on 2010-04-14.14:41:21 by pekka.klarck, last changed 2015-03-02.01:15:29 by zyasoft.

msg5701 (view) Author: Pekka Klärck (pekka.klarck) Date: 2010-04-14.14:41:19
I submitted issue #1594 about patterns like *.txt being processed incorrectly by jython.bat few days ago. I was able to find a solution to that problem, but now I've found more issues in handling arguments:

C:\>jython-orig -c "import sys; print sys.argv[1:]" foo%1
C:\>jython-orig -c "import sys; print sys.argv[1:]" foo! bar :zap

I got same results both with the original jython.bat distributed with 2.5.1 and with my version with the fix to #1594. The problem seems to be related to how arguments are evaluated in the following for loop inside :scanArgs helper. I didn't find any fix/workaround for it easily.

  for /f "tokens=1,*" %%i in (%_ARGS%) do call :getArg "%%i" "%%j"

The problem with %1 is pretty annoying in Robot Framework project [1], because we use that syntax with one of our command line arguments [2]. It works fine elsewhere than on Windows with Jython 2.5, it works even with Jython 2.2. The second problem is more obscure, but I can tell it's rather annoying to debug when it occurs. Based on these findings I'm also a little worried that other special characters may cause similar problems.

msg5806 (view) Author: Oti Humbel (otmarhumbel) Date: 2010-06-15.06:41:56

the % sign issue should be fixed with revision 7065 now (although i am missing the buildbot verification).
I'd appreciate it if you could give it a try using your robotframework.

Thanks in advance!
msg5807 (view) Author: Pekka Klärck (pekka.klarck) Date: 2010-06-15.06:52:19
Great! Is it enough to test this with the updated batch file or should I setup the Jython development environment and install the latest trunk version?
msg5808 (view) Author: Oti Humbel (otmarhumbel) Date: 2010-06-15.10:02:33
IMHO you should be fine by just grabbing the latest version of jython.bat
msg5809 (view) Author: Pekka Klärck (pekka.klarck) Date: 2010-06-15.10:49:03
Tested that %1, %2, etc. work as expected also with Robot Framework's --tagstatlink option. Thanks for the fix Oti!
msg5822 (view) Author: Pekka Klärck (pekka.klarck) Date: 2010-06-17.11:13:27
Noticed a bug in the new jython.bat. To reproduce:

1) Have the new jython.bat in the Jython installation directory (i.e. in the same directory with jython.jar).
2) Have Jython installation directory in PATH.
3) Create new batch file with following content:
set jython="jython.bat"
%jython%  --version
4) Run the batch
Execution fails with the following error:

Cannot find jython-dev.jar or jython.jar in
Try running this batch file from the 'bin' directory of an installed Jython,
or setting JYTHON_HOME.
msg5823 (view) Author: Oti Humbel (otmarhumbel) Date: 2010-06-17.11:19:23
I think this has to do with manually placing the .bat from trunk into the installation dir.

The long path would be to do a full build, install it, and try again.

A shorter way would be to simulate what the installer does: prepending some lines to jython.bat (check the original, installed one).

This is from top of my head and not verified. I'll check it this evening.
msg5824 (view) Author: Oti Humbel (otmarhumbel) Date: 2010-06-17.19:55:40
it worked for me - here is what i did:

a full-build with revision 7066, installed it: java -jar jython_installer-2.5.1-7066.jar -s -d c:/stuff/jython/jython-7066 -t all
and then:

C:\stuff\jython\jython-7066>type pekka.bat
set jython="jython.bat"
%jython%  --version
C:\stuff\jython\jython-7066>set jython="jython.bat"
C:\stuff\jython\jython-7066>"jython.bat"  --version
Jython 2.5.1+
msg5825 (view) Author: Pekka Klärck (pekka.klarck) Date: 2010-06-17.20:28:05
Great, thanks for testing Oti!
msg5969 (view) Author: Jim Baker (zyasoft) Date: 2010-08-15.17:05:28
Is this still open?
msg5973 (view) Author: Pekka Klärck (pekka.klarck) Date: 2010-08-15.19:05:22
According to Oti the problem with % has been fixed. This less severe, and more obscure, bug apparently is still there:

C:\>jython.bat -c "import sys; print sys.argv[1:]" foo! bar :zap

Perhaps a new issue should be opened for it and this one closed?
msg8147 (view) Author: Geoff Bache (geoffbache) Date: 2013-10-08.13:33:40
Just got bitten by this too. Jython seems to lose "!" characters passed on the command line.
msg9368 (view) Author: Jim Baker (zyasoft) Date: 2015-01-09.03:43:36
Underlying problem is #1491

#2056 is a duplicate
msg9539 (view) Author: Jim Baker (zyasoft) Date: 2015-02-22.06:23:02
#1491 is now fixed
Date User Action Args
2015-03-02 01:15:29zyasoftsetstatus: pending -> closed
2015-02-22 06:23:02zyasoftsetstatus: open -> pending
messages: + msg9539
2015-01-09 03:43:36zyasoftsetresolution: duplicate
messages: + msg9368
2013-10-08 13:33:41geoffbachesetnosy: + geoffbache
messages: + msg8147
2013-02-26 17:32:13fwierzbickisetnosy: + fwierzbicki
2010-08-15 19:05:22pekka.klarcksetmessages: + msg5973
2010-08-15 17:05:29zyasoftsetnosy: + zyasoft
messages: + msg5969
2010-06-17 20:28:06pekka.klarcksetmessages: + msg5825
2010-06-17 19:55:41otmarhumbelsetmessages: + msg5824
2010-06-17 11:19:24otmarhumbelsetmessages: + msg5823
2010-06-17 11:13:28pekka.klarcksetmessages: + msg5822
2010-06-15 10:49:04pekka.klarcksetmessages: + msg5809
2010-06-15 10:02:34otmarhumbelsetmessages: + msg5808
2010-06-15 06:52:19pekka.klarcksetmessages: + msg5807
2010-06-15 06:41:58otmarhumbelsetassignee: otmarhumbel
messages: + msg5806
nosy: + otmarhumbel
2010-04-14 14:41:21pekka.klarckcreate