Backslashes get lost when passing arguments to an external program via 
backquote command
----------------------------------------------------------------------------------------

                 Key: JRUBY-3203
                 URL: http://jira.codehaus.org/browse/JRUBY-3203
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.1.5
         Environment: Windows XP
            Reporter: David Jameson


I have some ruby code that invokes an external program I wrote in Delphi to set 
an environment variable in windows (by modifying the Windows registry) so that 
there's no need to reboot.
Typical usage is
   result = `setenv #{envName} \"#{envValue}\"`

(NB the escaped double quotes are just used to ensure that the second argument, 
which may have spaces, is seen as a single parameter)

This works perfectly fine in ruby 1.8

However, if I compile the code to a jruby class and run it, I find that path 
separators contained within the envValue (such as one would see if setting the 
PATH) are completely lost. Note that escaping the path separator with another 
backslash does not work...ALL the backslashes get lost. This was easily 
confirmed by having my Delphi program write the incoming arguments to STDERR

My workaround was to convert all path separators found in envValue to a 
different character not allowed in Windows paths and then my Delphi program 
undoes that change before setting the environment variable. Obviously, this 
workaround is not a general solution (but it lets me keep going :-)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to