On Thu, Feb 19, 2009 at 2:23 AM, Dan McGee <[email protected]> wrote: > On Wed, Feb 18, 2009 at 7:20 AM, Xavier Chantry <[email protected]> wrote: >> I initially only wanted to add a -l/--locate option to use locate instead of >> find, which should have been easy. >> >> Then I thought I would try to support filename with whitespaces while I was >> at it, and this was a bit more complex. The safest ways seem to be the >> following ones : http://mywiki.wooledge.org/BashFAQ/020 >> >> Then I received a lot of suggestions on #bash about how to improve the >> script, which I tried to address. >> >> Signed-off-by: Xavier Chantry <[email protected]> > Looks pretty good, one note inline. I've made the fix locally, so > don't worry about resubmitting. > >> --- >> contrib/pacdiff | 83 >> +++++++++++++++++++++++++++++++++++++------------------ >> 1 files changed, 56 insertions(+), 27 deletions(-) >> >> diff --git a/contrib/pacdiff b/contrib/pacdiff >> index 6493649..4b2aa9e 100755 >> --- a/contrib/pacdiff >> +++ b/contrib/pacdiff >> @@ -1,5 +1,5 @@ >> -#!/bin/sh >> -# pacdiff : a simple pacnew/pacorig/pacsave updater for /etc/ >> +#!/bin/bash >> +# pacdiff : a simple pacnew/pacorig/pacsave updater >> # >> # Copyright (c) 2007 Aaron Griffin <[email protected]> >> # >> @@ -17,29 +17,58 @@ >> # along with this program. If not, see <http://www.gnu.org/licenses/>. >> # >> >> -# Original http://phraktured.net/config/bin/pacdiff >> - >> diffprog=${DIFFPROG:-vimdiff} >> -for x in $(find /etc/ -name "*.pacnew" -o -name "*.pacorig" -o -name >> "*.pacsave") >> -do >> - echo "File: ${x%.pac*}" >> - chk="$(cmp $x ${x%.pac*})" >> - if [ -z "${chk}" ]; then >> - echo " Files are identical, removing..." >> - rm $x >> - else >> - echo -n " File differences found. (V)iew, (S)kip, (R)emove: >> [v/s/r] " >> - read c >> - c="$(echo $c| tr A-Z a-z)" #tolower >> - if [ "$c" = "r" ]; then >> - rm $x >> - elif [ "$c" = "s" ]; then >> - continue >> - else >> - [ "$c" = "n" -o "$c" = "N" ] || $diffprog $x ${x%.pac*} >> - echo -n " Remove file? [Y/n] " >> - read c >> - [ "$c" = "n" -o "$c" = "N" ] || rm $x >> - fi >> - fi >> -done >> +locate=0 >> + >> +usage() { >> + echo "pacdiff : a simple pacnew/pacorig/pacsave updater" >> + echo "Usage : pacdiff [-l]" >> + echo "The -l/--locate flag makes pacdiff use locate rather than find" >> +} >> + >> +cmd() { >> + if [ $locate -eq 1 ]; then >> + locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave >> + else >> + find /etc/ -name \*.pacnew -o -name \*.pacorig -o -name >> \*.pacsave -print0 > This didn't work out of the box. I had to use grouping to get it to > work correctly: > find /etc/ \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave \) > -print0 >
Arf sorry, probably my zsh shell would played me tricks again, I should always test with bash. _______________________________________________ pacman-dev mailing list [email protected] http://www.archlinux.org/mailman/listinfo/pacman-dev
