* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in media-tv/linuxtv-dvb-apps: ChangeLog linuxtv-dvb-apps-1.1.1.20070924.ebuild
2007-09-25 9:10 ` Robert Buchholz
@ 2007-09-25 14:45 ` Mike Frysinger
2007-09-25 23:02 ` Stephen Bennett
2007-09-26 9:38 ` [gentoo-dev] " Steve Long
2 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2007-09-25 14:45 UTC (permalink / raw
To: gentoo-dev; +Cc: Robert Buchholz, Donnie Berkholz, cardoe
[-- Attachment #1: Type: text/plain, Size: 631 bytes --]
On Tuesday 25 September 2007, Robert Buchholz wrote:
> On Tuesday, 25. September 2007, Donnie Berkholz wrote:
> > On 20:04 Mon 24 Sep , Doug Goldstein (cardoe) wrote:
> > > if ! use usb; then
> > > sed -i util/Makefile \
> > > -e '/ttusb_dec_reset/d' \
> > > -e '/dib3000-watch/d'
> > > fi
> > >
> > > # do not compile test-progs
> > > sed -i Makefile -e '/-C test/d'
> >
> > You might want to die if these seds fail.
>
> I already wondered a while back:
> sed only fails if the file does not exist, but not if there was no
> replacement. Is there any way to force it to?
i'm fairly certain the answer is no
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in media-tv/linuxtv-dvb-apps: ChangeLog linuxtv-dvb-apps-1.1.1.20070924.ebuild
2007-09-25 9:10 ` Robert Buchholz
2007-09-25 14:45 ` Mike Frysinger
@ 2007-09-25 23:02 ` Stephen Bennett
2007-09-26 5:44 ` Donnie Berkholz
2007-09-26 9:38 ` [gentoo-dev] " Steve Long
2 siblings, 1 reply; 9+ messages in thread
From: Stephen Bennett @ 2007-09-25 23:02 UTC (permalink / raw
To: gentoo-dev
On Tue, 25 Sep 2007 11:10:34 +0200
Robert Buchholz <rbu@gentoo.org> wrote:
> I already wondered a while back:
> sed only fails if the file does not exist, but not if there was no
> replacement. Is there any way to force it to?
Off the top of my head...
sed -e '1{x;s/^/0/;x;ta;:a}'
-e 's/$STRING/$REPLACEMENT/'
-e 'Tb;x;s/^/1/;x;:b;${p;x;/^0/Q1;Q0};'
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in media-tv/linuxtv-dvb-apps: ChangeLog linuxtv-dvb-apps-1.1.1.20070924.ebuild
2007-09-25 23:02 ` Stephen Bennett
@ 2007-09-26 5:44 ` Donnie Berkholz
2007-09-26 6:15 ` Mike Frysinger
0 siblings, 1 reply; 9+ messages in thread
From: Donnie Berkholz @ 2007-09-26 5:44 UTC (permalink / raw
To: gentoo-dev
On 00:02 Wed 26 Sep , Stephen Bennett wrote:
> On Tue, 25 Sep 2007 11:10:34 +0200
> Robert Buchholz <rbu@gentoo.org> wrote:
>
> > I already wondered a while back:
> > sed only fails if the file does not exist, but not if there was no
> > replacement. Is there any way to force it to?
>
> Off the top of my head...
>
> sed -e '1{x;s/^/0/;x;ta;:a}'
> -e 's/$STRING/$REPLACEMENT/'
> -e 'Tb;x;s/^/1/;x;:b;${p;x;/^0/Q1;Q0};'
I spent a few minutes trying to decipher that without luck. Could you
walk me through it?
Thanks,
Donnie
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in media-tv/linuxtv-dvb-apps: ChangeLog linuxtv-dvb-apps-1.1.1.20070924.ebuild
2007-09-26 5:44 ` Donnie Berkholz
@ 2007-09-26 6:15 ` Mike Frysinger
0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2007-09-26 6:15 UTC (permalink / raw
To: gentoo-dev; +Cc: Donnie Berkholz
[-- Attachment #1: Type: text/plain, Size: 1993 bytes --]
On Wednesday 26 September 2007, Donnie Berkholz wrote:
> On 00:02 Wed 26 Sep , Stephen Bennett wrote:
> > On Tue, 25 Sep 2007 11:10:34 +0200
> >
> > Robert Buchholz <rbu@gentoo.org> wrote:
> > > I already wondered a while back:
> > > sed only fails if the file does not exist, but not if there was no
> > > replacement. Is there any way to force it to?
> >
> > Off the top of my head...
> >
> > sed -e '1{x;s/^/0/;x;ta;:a}'
> > -e 's/$STRING/$REPLACEMENT/'
> > -e 'Tb;x;s/^/1/;x;:b;${p;x;/^0/Q1;Q0};'
>
> I spent a few minutes trying to decipher that without luck. Could you
> walk me through it?
sed maintains two buffers - pattern and hold (which start out empty) and
that's the trick here
{ } - used to group commands together
1 - only match first line (it's an address match)
x - swap pattern space and hold space
s/^/0/ - turn the (now) empty pattern space into "0"
x - swap pattern space and hold space
ta - branch to label a if previous expression matched something
a: - the actual label "a" ... needed to reset branching conditions
Tb - branch to label b if previous expression matched something
x - swap pattern space and hold space
s/^/1/ - insert "1" into the pattern space
x - swap pattern space and hold space
:b - the actual label "b'
$ - only match the last line (it's an address match)
p - print current pattern space
x - swap pattern space and hold space
/^0/Q1;Q0 - if the pattern space starts with a 0, exit with 1 ... otherwise
continue on to the exit with 0 ... either way, quit without printing
the optional argument to Q is a GNU extension which isnt documented in the
manpage :( ... guess i'll send them a patch
pretty sure the first expression can be dropped:
sed -e 's/$STRING/$REPLACEMENT/' \
-e 'tb;x;s/^/1/;x;:b;${p;x;/^$/Q1;Q0};'
and the printing makes it a little reliant on how sed is used ... i think
something like this should work with -n:
-e 'Tb;x;s/^/1/;x;:b;${x;/^$/{x;q1};x;q0}'
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gentoo-dev] Re: Re: [gentoo-commits] gentoo-x86 commit in media-tv/linuxtv-dvb-apps: ChangeLog linuxtv-dvb-apps-1.1.1.20070924.ebuild
2007-09-25 9:10 ` Robert Buchholz
2007-09-25 14:45 ` Mike Frysinger
2007-09-25 23:02 ` Stephen Bennett
@ 2007-09-26 9:38 ` Steve Long
2 siblings, 0 replies; 9+ messages in thread
From: Steve Long @ 2007-09-26 9:38 UTC (permalink / raw
To: gentoo-dev
Robert Buchholz wrote:
> On Tuesday, 25. September 2007, Donnie Berkholz wrote:
>> On 20:04 Mon 24 Sep , Doug Goldstein (cardoe) wrote:
>> > if ! use usb; then
>> > sed -i util/Makefile \
>> > -e '/ttusb_dec_reset/d' \
>> > -e '/dib3000-watch/d'
>> > fi
>> >
>> > # do not compile test-progs
>> > sed -i Makefile -e '/-C test/d'
>>
>> You might want to die if these seds fail.
>
> I already wondered a while back:
> sed only fails if the file does not exist, but not if there was no
> replacement. Is there any way to force it to?
>
ed will exit with an error if a regex doesn't match:
ed -s util/Makefile <<< 'H
/ttusb_dec_reset/d
/dib3000-watch/d
w
q' || die 'ohNoes!'
I prefer to mute errors in an ebuild (after testing):
ed -s Makefile 2>/dev/null <<< $'/-C test/d\nw\nq' \
|| die 'No match in Makefile'
..which I think is a lot easier to grok than the sed convolutions.
If it's supposed to be deleting every line with that regex (as the sed
currently does) I'd use: $'g/-C test/d\nw\nq'
I appreciate that ed seems hard (man ed is frightening!) but once you get
used to here-strings (and $' expansion) it's a doddle. (Use ,p instead of w
to see the output during testing.)
Tutorial: http://bash-hackers.org/wiki/doku.php?id=howto:edit-ed
Easier man page: http://plan9.bell-labs.com/magic/man2html/1/ed
Reference: http://www.opengroup.org/onlinepubs/009695399/utilities/ed.html
(I very much recommend that opengroup site as it outlines what a scripwriter
or programmer can expect on any POSIX/SuS compliant system.)
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [flat|nested] 9+ messages in thread