Gentoo Archives: gentoo-dev

From: Steve Long <slong@××××××××××××××××××.uk>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Re: Re: [gentoo-commits] gentoo-x86 commit in media-tv/linuxtv-dvb-apps: ChangeLog linuxtv-dvb-apps-1.1.1.20070924.ebuild
Date: Wed, 26 Sep 2007 09:53:38
Message-Id: fdd932$emi$1@sea.gmane.org
In Reply to: Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in media-tv/linuxtv-dvb-apps: ChangeLog linuxtv-dvb-apps-1.1.1.20070924.ebuild by Robert Buchholz
1 Robert Buchholz wrote:
2
3 > On Tuesday, 25. September 2007, Donnie Berkholz wrote:
4 >> On 20:04 Mon 24 Sep , Doug Goldstein (cardoe) wrote:
5 >> > if ! use usb; then
6 >> > sed -i util/Makefile \
7 >> > -e '/ttusb_dec_reset/d' \
8 >> > -e '/dib3000-watch/d'
9 >> > fi
10 >> >
11 >> > # do not compile test-progs
12 >> > sed -i Makefile -e '/-C test/d'
13 >>
14 >> You might want to die if these seds fail.
15 >
16 > I already wondered a while back:
17 > sed only fails if the file does not exist, but not if there was no
18 > replacement. Is there any way to force it to?
19 >
20 ed will exit with an error if a regex doesn't match:
21 ed -s util/Makefile <<< 'H
22 /ttusb_dec_reset/d
23 /dib3000-watch/d
24 w
25 q' || die 'ohNoes!'
26
27 I prefer to mute errors in an ebuild (after testing):
28 ed -s Makefile 2>/dev/null <<< $'/-C test/d\nw\nq' \
29 || die 'No match in Makefile'
30 ..which I think is a lot easier to grok than the sed convolutions.
31 If it's supposed to be deleting every line with that regex (as the sed
32 currently does) I'd use: $'g/-C test/d\nw\nq'
33
34 I appreciate that ed seems hard (man ed is frightening!) but once you get
35 used to here-strings (and $' expansion) it's a doddle. (Use ,p instead of w
36 to see the output during testing.)
37 Tutorial: http://bash-hackers.org/wiki/doku.php?id=howto:edit-ed
38 Easier man page: http://plan9.bell-labs.com/magic/man2html/1/ed
39 Reference: http://www.opengroup.org/onlinepubs/009695399/utilities/ed.html
40
41 (I very much recommend that opengroup site as it outlines what a scripwriter
42 or programmer can expect on any POSIX/SuS compliant system.)
43
44
45 --
46 gentoo-dev@g.o mailing list