Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#27299 closed defect (invalid)

defect: reinplace dequotes backslashes incompatibly with sed -E

Reported by: JamesC1 Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 1.9.2
Keywords: Cc:
Port:

Description

In the course of modifying the Portfile for firefox-x11-devel to build firefox 4.0b, I want this reinplace command:

reinplace -E "s:(libgtk-directfb-2.0).so.0:${prefix}/lib/\1.dylib:" ${worksrcpath}/dom/plugins/PluginModuleChild.cpp

The \1 works in sed -E on the command-line, and substitutes back in a copy of the library name.

After port install, the resulting line in the file reads (in vi):

sGtkLib = PR_LoadLibrary("/opt/local/lib/^A.dylib");

I have inserted some debug output into portutil.tcl. This is one of several attempts, so the line numbers will not agree with your copies.

 # reinplace
 # Provides "sed in place" functionality
 proc reinplace {args}  {
 
+    puts "Because I want to know (args): >>$args<<"
+
     set extended 0
     while 1 {
         set arg [lindex $args 0]
@@ -905,6 +932,9 @@
             lappend cmdline $portutil::autoconf::sed_ext_flag
         }
         set cmdline [concat $cmdline [list $pattern < $file >@ $tmpfd]]
+
+        puts "Because I want to know (sed): >>$cmdline<<"
+

The output I get (which I am wrappng for convenience) from this reads:

Because I want to know (args): >>-E 
  s:(libgtk-directfb-2.0).so.0:/opt/local/lib/.dylib: 
  /opt/local/var/macports/build/
  _Users_jamescone_buildTrees_macports_www_firefox-x11-devel/work/
  mozilla-central/dom/plugins/PluginModuleChild.cpp<<

Because I want to know (sed): >>/usr/bin/sed -E 
  s:(libgtk-directfb-2.0).so.0:/opt/local/lib/.dylib: 
  < /opt/local/var/macports/build/
  _Users_jamescone_buildTrees_macports_www_firefox-x11-devel/work/
  mozilla-central/dom/plugins/PluginModuleChild.cpp >@ file11<<

I assume that there is an invisible control-A in these two lines of printout, before the .dylib. In any event, they show that the sed command is already mangled, before reinplace is called.

I have worked out that the portfile is parsed into a set of runtime-created proc's, but I cannot work out enough of the details to localise the fault.

Help, please.

Change History (3)

comment:1 Changed 14 years ago by jmroot (Joshua Root)

Resolution: invalid
Status: newclosed

This is just how Tcl's parser works and we can't really do anything about it. Add additional quoting or escaping as needed, which should be one more backslash in this case.

comment:2 Changed 14 years ago by JamesC1

Inserting an explanation for the next confused person.

It's at least partly a feature. As JRM says, the portfile is parsed with the ordinary tcl parser, and happens before anything we can see in the callstack.

Tcl recognises two kinds of strings.

"This kind" does both dollar ($) and backslash (\) substitution before anything I can see gets the data.

{This kind} does neither.

I want dollar substitutions, but not backslash substitutions.

I intend to implement a new option in reinplace, to undo the backslash substitutions. When it's working for me I will open a new ticket as an enhancement.

comment:3 Changed 14 years ago by JamesC1

The feature request is here: https://trac.macports.org/ticket/27310

Note: See TracTickets for help on using tickets.