[GRASS-dev] [GRASS GIS] #2314: output r.out.xyz

GRASS GIS trac at osgeo.org
Sun Jun 1 20:37:00 PDT 2014


#2314: output r.out.xyz
-------------------------------------------------+--------------------------
 Reporter:  pvanbosgeo                           |       Owner:  grass-dev@…              
     Type:  defect                               |      Status:  new                      
 Priority:  normal                               |   Milestone:  7.0.0                    
Component:  Default                              |     Version:  svn-trunk                
 Keywords:  separator, pipe, r.out.xyz, r.stats  |    Platform:  MSWindows 7              
      Cpu:  All                                  |  
-------------------------------------------------+--------------------------

Comment(by glynn):

 Replying to [comment:26 hcho]:

 > > Er, sort of. It quotes it, but the shell interprets | (and < and >)
 even when quoted.
 >
 > Quoting didn't help. I had to escape special characters with {{{^^^}}}
 in r60634.

 r60634 appears to relate to wxGUI, which won't have any effect upon
 running the script normally. Also, it appears to apply the escaping
 regardless of whether shell=True or shell=False.

 > It looks like subprocess.Popen(shell=True) calls cmd.exe twice, so
 double escaping was needed.

 Setting shell=True prepends "cmd.exe /c " to the command string. If the
 command is a .bat file, that would probably result in additional parsing.

 > E.g., to escape {{{|}}}, {{{^^^|}}}} needs to be fed into cmd.exe, but
 since cmd.exe is called twice, three {{{^}}} becomes six {{{^}}} and
 {{{|}}} becomes {{{^|}}}. So we need {{{^^^^^^^|}}}. I tested r60634 on
 Windows 7 with trunk and it worked.

 I think that the only robust solution here is to remove the shell from the
 equation altogether. The quoting required for MSVCRT is ugly enough, and
 adding another layer of quoting for cmd.exe makes it even worse. And there
 may be issues other than quoting waiting to be discovered (cmd.exe isn't
 particularly well documented, compared to e.g. the bash manual which runs
 to around 80 pages).

 > Now back to G_OPT_F_SEP, since we fixed {{{|}}}, showing {{{|}}} or pipe
 as default is a preference only.

 No, we haven't fixed | yet. I think that modifying grass.Popen() not to
 use shell=True should fix it, but I don't know what relies upon the
 existing behaviour, or what to replace it with.

 > Regarding the backtick issue, it was not exactly an issue because
 cmd.exe does not support backticks anyway.

 It does in the "for" command, which is sometimes used solely for its
 backtick feature; but that's a fairly ugly hack, and not something which
 should be suggested to users.

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/2314#comment:29>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list