On 04/07/2011 01:26 PM, Laine Stump wrote: > On 04/05/2011 06:51 PM, Eric Blake wrote: >> Make it so we don't have to 'git add -f' particular files like >> po/POTFILES.in all the time (tested by fixing one of our >> special-case files as part of the patch). >> >> * .gnulib: Update to latest. >> * bootstrap: Resync from coreutils. >> * .gitignore: Sort whitelist entries correctly, including ignoring >> files rather than directories. >> * m4/virt-compile-warnings.m4: Convert tabs to space. >> --- > > ACK (once Eric explained the sed construct I'd never seen before :-) Thanks; pushed. > >> +# Ensure that lines starting with ! sort last, per gitignore conventions >> +# for whitelisting exceptions after a more generic blacklist pattern. >> +sort_patterns() { >> + sort -u "$@" | sed Sed has two buffers - the pattern space (which gets printed for every line of input unless it is empty) and the hold space (which is used for scratch work). '/^!/ { >> + H >> + d >> + } For all lines that start with !, append a newline and that line into the hold space, then delete the line from the pattern space (so skip printing ! lines the first time through). >> + $ { >> + P >> + x >> + s/^\n// >> + }' On the last line, print the line like normal, then exchange pattern and buffer spaces, remove the extra leading newline that got put in the hold space on the first ! line, then print all the deferred ! lines. > Yeah, that's the one... I don't blame you for asking - sed's got some pretty arcane (but cool) features. -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list