New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #27310 (closed enhancement: wontfix)

Opened 3 years ago

Last modified 3 years ago

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

Reported by: james.from.wellington@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 1.9.2
Keywords: haspatch Cc: ryandesign@…
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

reinplace-backslash-patch.diff (1.1 KB) - added by james.from.wellington@… 3 years ago.

Change History

Changed 3 years ago by james.from.wellington@…

comment:1 follow-up: ↓ 3 Changed 3 years ago by 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.

comment:2 follow-up: ↓ 4 Changed 3 years ago by james.from.wellington@…

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 3 years ago by jmr@…

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 3 years ago by ryandesign@…

  • Status changed from new to closed
  • Resolution set to wontfix

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 3 years ago by ryandesign@…

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