Sat, 21 Apr 2007

* Kragen Javier Sitaker <kragen at pobox.com> [2007-04-21 09:40]:
> #!/bin/sh
> set -e
> usage="Usage: $0 checkpoint.tar.gz"
> : ${1?$usage}
> mkdir old
> trap 'rm -rf old' 0
> (cd old; tar xzf ../"$1")
> dir="$(ls old | head -1)"
> diff -urN old/"$dir" "$dir"

You can use mktemp(1) to make this robust. Also note that the $()
syntax for command substitution is a bash innovation, so the
/bin/sh shebang is wrong. Lastly, GNU and BSD tar have a handy -C
switch.

    #!/bin/bash
    set -e
    usage="Usage: $0 checkpoint.tar.gz"
    : ${1?$usage}
    TMPDIR=`mktemp -d`
    mkdir "$TMPDIR"
    trap 'rm -rf "$TMPDIR"' 0
    tar xzf "$1" -C "$TMPDIR"
    dir="$(ls "$TMPDIR" | head -1)"
    diff -urN "$TMPDIR/$dir" "$dir"

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

So I'm using Beatrice's Mac, which doesn't have darcs.  It does have
CVS, but after using darcs, CVS feels clumsy.  So I wrote this shell
script to diff a directory from a tarballed checkpoint of it.  Don't
use it if you have directories sitting around called 'old'.

#!/bin/sh
set -e
usage="Usage: $0 checkpoint.tar.gz"
: ${1?$usage}
mkdir old
trap 'rm -rf old' 0
(cd old; tar xzf ../"$1")
dir="$(ls old | head -1)"
diff -urN old/"$dir" "$dir"