From: Ryan Hill <dirtyepic@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] Re: RFC: sed script redundancy
Date: Thu, 27 Oct 2011 19:08:36 -0600 [thread overview]
Message-ID: <20111027190836.28f911fe@gentoo.org> (raw)
In-Reply-To: 20110520173922.391ea292@epia.jer-c2.orkz.net
[-- Attachment #1: Type: text/plain, Size: 1772 bytes --]
On Fri, 20 May 2011 17:39:22 +0200
Jeroen Roovers <jer@gentoo.org> wrote:
> for a while now I've been wondering if all those sed scripts in all
> those ebuilds are really effective.
>
> To find out, I've tried a couple of angles on a sed hook that basically
> dissects the sed command line provided, divides everything up into sed
> scripts, files being processed and other options, and runs everything
> through diff to get some meaningful QA output as to the effective use
> of the sed scripts invoked.
>
> Of course some of the time a sed script falsely seems to be ineffective,
> but could be, when it uses some variable or output that varies depending
> on the platform you run it on, like with the likes of $(get_libdir).
>
> I've looked into sed's internal solutions to no avail, but something
> like -i[SUFFIX] might help, since it gives you a backup file to compare
> with the file that's being streamed.
>
> The idea is to pass the result to
> | diff -u $file $file[SUFFIX]
> to figure out what was changed, and what sed script changed it.
>
> Any help?
Sorry, old thread. :) You can use the 'w' flag to write a log file of lines
changed. This includes lines changed where the replacement ended up the same
as the text matched (eg. lib->$(get_libdir)). Which means you can do
something like:
dirtyepic@tundra ~ $ cat test
foo
foobar
bar
foobarfoo
dirtyepic@tundra ~ $ sed -i -e 's:foo:foo:gw /dev/stdout' test | wc -l
3
I think only gnu sed can do the stdout thing.
--
fonts, gcc-porting, it makes no sense how it makes no sense
toolchain, wxwidgets but i'll take it free anytime
@ gentoo.org EFFD 380E 047A 4B51 D2BD C64F 8AA8 8346 F9A4 0662
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2011-10-28 0:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-20 15:39 [gentoo-dev] RFC: sed script redundancy Jeroen Roovers
2011-05-20 15:56 ` Fabian Groffen
2011-05-21 17:34 ` Jeroen Roovers
2011-05-22 10:50 ` Fabian Groffen
2011-05-29 10:44 ` Christopher Schwan
2011-05-29 11:00 ` Fabian Groffen
2011-05-29 11:49 ` Christopher Schwan
2011-10-28 1:08 ` Ryan Hill [this message]
2013-06-10 3:47 ` Jeroen Roovers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111027190836.28f911fe@gentoo.org \
--to=dirtyepic@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox