Menu

#961 Console: handling spaces on command line (windows)

None
closed-fixed
None
5
2014-07-10
2008-02-16
Rômulo C
No

Console 4.3.5
jEdit 4.3pre12
Java 1.6.0_02
WinXP SP2.

Since I don't like to keep every interpreter in the system path of my Windows box, I had to hack a python commando file so that it includes the full interpreter path. But because of the way the Console plugin evaluates the command line with "cmd /c" and because of the way cmd.exe handles quotes, I cannot simply make the commando script build a command like this:

"C:\Arquivos de programas\Python 2.5\python.exe" -t "D:\Profiles\Aurelio\Meus documentos\Bin\fixmigrations.py"

To execute that with "cmd /c" I need to write:

cmd /c """"C:\Arquivos de programas\Python 2.5\python.exe""" -t ^"D:\Profiles\Aurelio\Meus documentos\Bin\fixmigrations.py^""

However, if I make the command like that (without the leading "cmd /c") Console throws an exception when executing it:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0

It looks like Console tries to handle the already built string in some strange way, because, if I put a space after the first quote:

" """C:\Arquivos de programas\Python 2.5\python.exe""" -t ^"D:\Profiles\Aurelio\Meus documentos\Bin\fixmigrations.py^""

the plugin doesn't throw any exception, but the command line it sends to the operating system becomes seriously corrupted (taken from Process Monitor):

cmd /c " " C:\Arquivos de programas\Python 2.5\python.exe " -t ^" D:\Profiles\Aurelio\Meus documentos\Bin\fixmigrations.py^ " "

Discussion

  • Rômulo C

    Rômulo C - 2008-02-16

    Logged In: YES
    user_id=1054355
    Originator: YES

    Although this doesn't render the bug any less valid, one can workaround the problem by using parenthesis instead of quotes:

    cmd /c ("C:\Arquivos de programas\Python 2.5\python.exe" -t "D:\Profiles\Aurelio\Meus documentos\Bin\fixmigrations.py")

     
  • Alan Ezust

    Alan Ezust - 2012-01-29
    • summary: Console: handling problem on unusual command line --> Console: handling spaces on command line (windows)
     
  • Alan Ezust

    Alan Ezust - 2012-01-29

    Ticket 2438719 was marked as a duplicate of this bug.

     
  • Damien

    Damien - 2012-03-08

    Just committed a potential fix as revision 21279. The default behavior when running windows commands is now to wrap the whole command in parentheses, e.g. cmd.exe /c ( ... ). This essentially makes your workaround a permanent solution.

    I'm closing this bug, but if issues still come up with Console's latest trunk, please let me know.

     
  • Alan Ezust

    Alan Ezust - 2014-07-10

    Adding round brackets around argument lists in Windows is now a new option you can switch on for this behavior.

     

Log in to post a comment.