reinplace first occurrence

classic Classic list List threaded Threaded
4 messages Options
db
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

reinplace first occurrence

db
I checked portfile's man page and peaked at the source, but couldn't figure out yet, why these forms don't work.

https://stackoverflow.com/a/11458836/2167331

In the meantime, I worked around it, but I'd still like to know how to do it.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: reinplace first occurrence

Ryan Schmidt-24
On Aug 3, 2017, at 09:44, db wrote:
>
> I checked portfile's man page and peaked at the source, but couldn't figure out yet, why these forms don't work.
>
> https://stackoverflow.com/a/11458836/2167331
>
> In the meantime, I worked around it, but I'd still like to know how to do it.

Well the stack overflow answer says non-GNU sed doesn't support the single-command version, and needs a two-command version. reinplace doesn't support executing multiple commands.

You could run a two-command sed manually (with system, not reinplace). Or maybe you can use awk, or an ed script.

I can't remember anybody asking for this functionality (replace first occurrence) before, so that's why there isn't an easy way to do it.
db
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: reinplace first occurrence

db
On 3 Aug 2017, at 18:46, Ryan Schmidt <[hidden email]> wrote:
> You could run a two-command sed manually (with system, not reinplace). Or maybe you can use awk, or an ed script.

This works. Caveat emptor: || (empy RE) doesn't work and range seems to start on first line, not on its subsequent.

reinplace -E 1,/foo/s|foo|foo\\\n\\\tbar| file

> I can't remember anybody asking for this functionality (replace first occurrence) before, so that's why there isn't an easy way to do it.

I needed to add disabled/true to a startup item provided by a port's source.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: reinplace first occurrence

Ryan Schmidt-24
On Aug 3, 2017, at 15:19, db wrote:

> On 3 Aug 2017, at 18:46, Ryan Schmidt wrote:
>
>> I can't remember anybody asking for this functionality (replace first occurrence) before, so that's why there isn't an easy way to do it.
>
> I needed to add disabled/true to a startup item provided by a port's source.

Seems like a place to use a patch file.
Loading...