[prev in list] [next in list] [prev in thread] [next in thread]
List: gentoo-dev
Subject: [gentoo-dev] Re: RFC: sed script redundancy
From: Ryan Hill <dirtyepic () gentoo ! org>
Date: 2011-10-28 1:08:36
Message-ID: 20111027190836.28f911fe () gentoo ! org
[Download RAW message or body]
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
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic