I was looking at UML this morning. I wanted a Win32 port.
I downloaded the patch to the latest stable 2.4 kernel.

[ done while looking over the LINE 0.5 code (think Lin4Win :) ]

But I'll never get started with distractions like these...

... I wanted to look at said patch file in a non-linear fashion. :)

It contains diffs for a large number of files in the kernel tree, and I
wanted an overall picture, not the line-by-line view I was getting.
I wanted to extract those diffs into their proper tree, without patching.

... enter grep.

I could grep for all lines containing 'diff'. That would show me all
modified/added files, but looking up more detail was still tedious.

... enter a monster...  :)

cat uml-patch-2_4_18-10 | {
        while read LINE; do
                set -- $LINE
                if [ "$1" = "diff" ]; then
                        echo
                        while [ "$2" ]; do shift; done
                        FILE="$1.diff"
                        if [ -e $FILE ]; then
                                echo skipping $FILE
                                FILE=
                        else 
                                echo creating $FILE
                                mkdirhier `dirname $FILE`
                        fi
                fi
                echo -n .
                [ "$FILE" ] && echo "$LINE" >> $FILE
        done
}

... enter bright idea

. o O (Maybe someone else wants to do this)
. o O (If I post it to slug, it'll pop up in the archive search...)

... footnote

I used set/shift to set the args and pick out the first/last words so bash
didn't have to spawn a subprocess. I normally would've used 'cut', but
doing it for every line slowed things down a lot.

... apologies

This was probably a waste of bandwidth.
There's probably a proper tool somewhere to do the job.
Yes, I'm sure scripting in ZSH could've done it better. :-P

-- Jessica Mayo.
(Everything with a Grin :)


-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to