Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#27310 closed enhancement (wontfix)

Feature request: -u option to reinplace, to facilitate \[0-9] copy into replacement

Reported by: JamesC1 Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 1.9.2
Keywords: haspatch Cc: ryandesign (Ryan Carsten Schmidt)
Port:

Description

In the course of updating firefox-x11-devel, I wanted reinplace commands that look like this (modulo the new option):

    reinplace -u -E "s:(libplayback-1).so.0:${prefix}/lib/\1.dylib:" \
      ${worksrcpath}/modules/plugin/base/src/nsPluginNativeWindowGtk2.cpp

where the \1 copies the library name into the replacement text.

They work fine in sed, but did not work in macports because \1 is a tcl escape sequence for control-A.

This patch provides the -u option (shown above) to convert control-A to control-H into \1 to \7, assuming that they are the remains of escape sequences, enabling the command in the Portfile to be tested by copy-pasting into command-line sed without a lot of editing.

This ticket is a continuation of https://trac.macports.org/ticket/27299

Attachments (1)

reinplace-backslash-patch.diff (1.1 KB) - added by JamesC1 14 years ago.

Download all attachments as: .zip

Change History (6)

Changed 14 years ago by JamesC1

comment:1 Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)

Can't this already be accomplished without changing base by just doubling the backslashes before the numbers? I'm sure we already do this in tons of ports.

comment:2 Changed 14 years ago by JamesC1

I wouldn't know. If the rules are explained in the documentation, it's not obvious to me.

I like this because it enables me to paste the pattern into command-line sed for testing, when it doesn't work.

comment:3 in reply to:  1 Changed 14 years ago by jmroot (Joshua Root)

Replying to ryandesign@…:

Can't this already be accomplished without changing base by just doubling the backslashes before the numbers? I'm sure we already do this in tons of ports.

Yes. This isn't peculiar to reinplace either, you have to do the same thing when constructing a string to be run as a shell command for example. If you want a literal string, use braces. If you want some but not all of the normal substitutions, call subst(n) on your literal string with appropriate options.

comment:4 in reply to:  2 Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: wontfix
Status: newclosed

See for example the apache2 port which has:

post-patch {
    reinplace -E "s/(User|Group) daemon/\\1 www/" ${worksrcpath}/docs/conf/httpd.conf.in
}

I don't doubt our Guide is incomplete in this and many other respects. Patches to improve the documentation are welcome.

comment:5 Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added
Note: See TracTickets for help on using tickets.