From 2ae5371f347603d34a7ccc33681e612db338d11e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 1 May 2017 17:46:32 -0400 Subject: Have everything use a main() function, where it isn't too tricky to convert "Ignore space change" is essential to making sense of this patch. --- src/repo-diff | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'src/repo-diff') diff --git a/src/repo-diff b/src/repo-diff index 10b617c..ab7aaed 100755 --- a/src/repo-diff +++ b/src/repo-diff @@ -30,11 +30,6 @@ usage() { flag 'parabola' 'expands to Parabola GNU/Linux-libre repo url' } -if test $# -eq 0; then - usage - exit 0 -fi - b() { bsdtar ztf "$1" | cut -d "/" -f1 | sort -u ; } n() { echo "$1".db | tr "/" "-"; } @@ -49,28 +44,37 @@ g() { -e "s,^arch\(linux\)\?/,http://mirrors.kernel.org/archlinux/," } -mkdir ${0##*/}.$$ -pushd ${0##*/}.$$ >/dev/null +main() { + if test $# -eq 0; then + usage + exit 0 + fi + + mkdir ${0##*/}.$$ + pushd ${0##*/}.$$ >/dev/null -d="" -for i in $1 $2; do - n=$(n "$i") + d="" + for i in $1 $2; do + n=$(n "$i") - test -z "$n" && exit 1 + test -z "$n" && exit 1 - wget -O "$n" -nv $(g "$i") - b "$n" >${n}.orig + wget -O "$n" -nv $(g "$i") + b "$n" >${n}.orig - d+=" ${n}.orig" -done + d+=" ${n}.orig" + done -{ - printf "$(gettext "Difference between %s and %s")\n---\n" $1 $2 - which diffstat &>/dev/null && diff -auN "${d[@]}" | diffstat - diff -auN "${d[@]}" -} >../${n}.diff + { + printf "$(gettext "Difference between %s and %s")\n---\n" $1 $2 + which diffstat &>/dev/null && diff -auN "${d[@]}" | diffstat + diff -auN "${d[@]}" + } >../${n}.diff -popd >/dev/null -rm -r ${0##*/}.$$ + popd >/dev/null + rm -r ${0##*/}.$$ + + print "Difference save on %s" "${n}.diff" +} -print "Difference save on %s" "${n}.diff" +main "$@" -- cgit v1.2.2