~nabijaczleweli/ossp-cvs

[CVS] OSSP: ossp-pkg/svs/ ChangeLog svs.sh

Ralf S. Engelschall <rse@ossp.org>
Details
Message ID
<20090625181042.1069D752861@mail.ossp.org>
Sender timestamp
1245960642
DKIM signature
missing
Download raw message
  OSSP CVS Master Repository
  http://cvs.ossp.org/
  ____________________________________________________________________________

  Server: cvs.ossp.org                     Name:   Ralf S. Engelschall
  Root:   /v/ossp/cvs                      Email:  rse@ossp.org
  Module: ossp-pkg                         Date:   25-Jun-2009 20:10:42
  Branch: HEAD                             Handle: 2009062519104100

  Modified files:
    ossp-pkg/svs            ChangeLog svs.sh

  Log:
    Support directories and files with spaces in the name.

  Summary:
    Revision    Changes     Path
    1.11        +3  -0      ossp-pkg/svs/ChangeLog
    1.11        +64 -51     ossp-pkg/svs/svs.sh
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: ossp-pkg/svs/ChangeLog
  ============================================================================
  $ cvs diff -u -r1.10 -r1.11 ChangeLog
  --- ossp-pkg/svs/ChangeLog	25 Jun 2009 18:09:59 -0000	1.10
  +++ ossp-pkg/svs/ChangeLog	25 Jun 2009 18:10:41 -0000	1.11
  @@ -10,6 +10,9 @@
   
     Changes between 1.0.5 and 1.1.0 (07-Oct-2005 to 25-Jun-2009):
   
  +    *) Support directories and files with spaces in the name.
  +       [Ralf S. Engelschall]
  +
       *) Upgrade build environment to GNU autoconf 2.63 and GNU shtool 2.0.8
          [Ralf S. Engelschall]
   
  @@ .
  patch -p0 <<'@@ .'
  Index: ossp-pkg/svs/svs.sh
  ============================================================================
  $ cvs diff -u -r1.10 -r1.11 svs.sh
  --- ossp-pkg/svs/svs.sh	7 Oct 2005 10:59:27 -0000	1.10
  +++ ossp-pkg/svs/svs.sh	25 Jun 2009 18:10:41 -0000	1.11
  @@ -39,18 +39,22 @@
   
   #   helper function for portable creating a file difference
   do_diff () {
  -    diff -U3 $1 $2 2>/dev/null
  +    diff -U3 "$1" "$2" 2>/dev/null
       if [ $? -gt 1 ]; then
  -        diff -u $1 $2 2>/dev/null
  +        diff -u "$1" "$2" 2>/dev/null
           if [ $? -gt 1 ]; then
  -            diff -C3 $1 $2 2>/dev/null
  +            diff -C3 "$1" "$2" 2>/dev/null
               if [ $? -gt 1 ]; then
  -                diff $1 $2
  +                diff "$1" "$2"
               fi
           fi
       fi
   }
   
  +#   a newline character
  +NL='
  +'
  +
   #   dispatch into commands
   cmd="$1"
   shift
  @@ -63,34 +67,34 @@
           #   iterate over all files
           for file in "$@"; do
               #   preserve original file
  -            if [ ! -f $file.orig ]; then
  -                cp -p $file $file.orig
  +            if [ ! -f "$file.orig" ]; then
  +                cp -p "$file" "$file.orig"
                   orig=new
               else
                   orig=old
               fi
   
               #   edit file
  -            chmod u+w $file
  -            if [ ".${EDITOR-vi}" = .vim -a -f $file.rej ]; then
  -                ${EDITOR-vi} -o2 $file $file.rej
  +            chmod u+w "$file"
  +            if [ ".${EDITOR-vi}" = .vim -a -f "$file.rej" ]; then
  +                ${EDITOR-vi} -o2 "$file" "$file.rej"
               else
  -                ${EDITOR-vi} $file
  +                ${EDITOR-vi} "$file"
               fi
   
               #   check for editing results
  -            if cmp $file.orig $file >/dev/null 2>&1; then
  +            if cmp "$file.orig" "$file" >/dev/null 2>&1; then
                   if [ ".$orig" = .new ]; then
                       echo "svs: no changes made (keeping original)"
                   else
                       echo "svs: changes reversed (restoring original)"
                   fi
  -                cp -p $file.orig $file
  -                rm -f $file.orig
  +                cp -p "$file.orig" "$file"
  +                rm -f "$file.orig"
               else
                   echo "svs: changes made (preserving original)"
  -                if [ -f $file.rej ]; then
  -                    rm -f $file.rej
  +                if [ -f "$file.rej" ]; then
  +                    rm -f "$file.rej"
                   fi
               fi
           done
  @@ -107,12 +111,14 @@
           fi
           files=""
           for file in "$@"; do
  -            if [ -d $file ]; then
  -                for f in `find $file -type f -name "*.orig" -print | sort`; do
  -                    files="$files $f"
  +            if [ -d "$file" ]; then
  +                OIFS=$IFS; IFS=$NL
  +                for f in `find "$file" -type f -name "*.orig" -print | sort`; do
  +                    files="$files \"$f\""
                   done
  -            elif [ -f $file ]; then
  -                files="$files $file"
  +                IFS=$OIFS
  +            elif [ -f "$file" ]; then
  +                files="$files \"$file\""
               else
                   echo "svs:ERROR: \"$file\" neither regular file nor directory" 1>&2
                   exit 1
  @@ -120,29 +126,30 @@
           done
   
           #   generate patch
  -        for file in $files; do
  +        eval set -- $files
  +        for file; do
               file=`echo "$file" | sed -e 's;^\./;;' -e 's;/\./;/;g' -e 's;\([^/][^/]*\)/\.\.;;g' -e 's;//*;/;g'`
               orig=`echo "$file" | sed -e 's;\.orig$;;' -e 's;$;.orig;'`
               edit=`echo "$file" | sed -e 's;\.orig$;;'`
  -            if [ ! -f $orig ]; then
  +            if [ ! -f "$orig" ]; then
                   echo "svs:WARNING: original file \"$orig\" not found" 1>&2
                   continue
               fi
  -            if [ ! -f $edit ]; then
  +            if [ ! -f "$edit" ]; then
                   #   special case: removed file
                   echo "Index: $edit"
  -                do_diff $orig /dev/null | sed -e "1s/^--- $orig/--- $edit/"
  -            elif [ ! -r $orig ] && [ ! -s $orig ]; then
  +                do_diff "$orig" /dev/null | sed -e "1s/^--- $orig/--- $edit/"
  +            elif [ ! -r "$orig" ] && [ ! -s "$orig" ]; then
                   #   special case: new file
                   echo "Index: $edit"
  -                do_diff /dev/null $edit
  +                do_diff /dev/null "$edit"
               else
                   #   regular case: edited file
  -                if cmp $orig $edit >/dev/null 2>&1; then
  +                if cmp "$orig" "$edit" >/dev/null 2>&1; then
                       :
                   else
                       echo "Index: $edit"
  -                    do_diff $orig $edit
  +                    do_diff "$orig" "$edit"
                   fi
               fi
           done
  @@ -159,12 +166,14 @@
           fi
           files=""
           for file in "$@"; do
  -            if [ -d $file ]; then
  -                for f in `find $file -type f -name "*.orig" -print | sort`; do
  -                    files="$files $f"
  +            if [ -d "$file" ]; then
  +                OIFS=$IFS; IFS=$NL
  +                for f in `find "$file" -type f -name "*.orig" -print | sort`; do
  +                    files="$files \"$f\""
                   done
  -            elif [ -f $file ]; then
  -                files="$files $file"
  +                IFS=$OIFS
  +            elif [ -f "$file" ]; then
  +                files="$files \"$file\""
               else
                   echo "svs:ERROR: \"$file\" neither regular file nor directory" 1>&2
                   exit 1
  @@ -172,28 +181,29 @@
           done
   
           #   backout changes
  -        for file in $files; do
  +        eval set -- $files
  +        for file; do
               file=`echo "$file" | sed -e 's;^\./;;' -e 's;/\./;/;g' -e 's;\([^/][^/]*\)/\.\.;;g' -e 's;//*;/;g'`
               orig=`echo "$file" | sed -e 's;\.orig$;;' -e 's;$;.orig;'`
               edit=`echo "$file" | sed -e 's;\.orig$;;'`
  -            if [ ! -f $orig ]; then
  +            if [ ! -f "$orig" ]; then
                   echo "svs:WARNING: original file \"$orig\" not found" 1>&2
                   continue
               fi
               echo "svs: backing out changes to \"$edit\""
  -            if [ ! -f $edit ]; then
  +            if [ ! -f "$edit" ]; then
                   #   special case: removed file
  -                cp -p $orig $edit
  -                rm -f $orig
  -            elif [ ! -r $orig ] && [ ! -s $orig ]; then
  +                cp -p "$orig" "$edit"
  +                rm -f "$orig"
  +            elif [ ! -r "$orig" ] && [ ! -s "$orig" ]; then
                   #   special case: new file
  -                chmod u+w $orig
  -                rm -f $orig
  -                rm -f $edit
  +                chmod u+w "$orig"
  +                rm -f "$orig"
  +                rm -f "$edit"
               else
                   #   regular case: edited file
  -                cp -p $orig $edit
  -                rm -f $orig
  +                cp -p "$orig" "$edit"
  +                rm -f "$orig"
               fi
           done
           ;;
  @@ -209,16 +219,18 @@
           fi
           files=""
           for file in "$@"; do
  -            if [ -d $file ]; then
  -                for f in `find $file -type f \( -name "*.orig" -or -name "*.rej" \) -print | sort`; do
  +            if [ -d "$file" ]; then
  +                OIFS=$IFS; IFS=$NL
  +                for f in `find "$file" -type f \( -name "*.orig" -or -name "*.rej" \) -print | sort`; do
                       base=`echo "$f" | sed -e 's;\.orig$;;' -e 's;\.rej$;;'`
  -                    if [ ".$f" = ".$base.orig" ] && [ -f $base.orig ] && [ -f $base.rej ]; then
  +                    if [ ".$f" = ".$base.orig" ] && [ -f "$base.orig" ] && [ -f "$base.rej" ]; then
                           continue
                       fi
  -                    files="$files $f"
  +                    files="$files \"$f\""
                   done
  -            elif [ -f $file ]; then
  -                files="$files $file"
  +                IFS=$OIFS
  +            elif [ -f "$file" ]; then
  +                files="$files \"$file\""
               else
                   echo "svs:ERROR: \"$file\" neither regular file nor directory" 1>&2
                   exit 1
  @@ -226,7 +238,8 @@
           done
   
           #   show status on files
  -        for file in $files; do
  +        eval set -- $files
  +        for file; do
               file=`echo "$file" | sed -e 's;^\./;;' -e 's;/\./;/;g' -e 's;\([^/][^/]*\)/\.\.;;g' -e 's;//*;/;g'`
               base=`echo "$file" | sed -e 's;\.orig$;;' -e 's;\.rej$;;'`
               prefix="?"
  @@ .
Reply to thread Export thread (mbox)