diff options
author | hubertf <hubertf@pkgsrc.org> | 2001-01-18 17:04:21 +0000 |
---|---|---|
committer | hubertf <hubertf@pkgsrc.org> | 2001-01-18 17:04:21 +0000 |
commit | 4597d80670e391df43162b8ee3b4357d8332d270 (patch) | |
tree | 3b5932caa89b9839b524e9f5ee0f1f51d0bc41c7 /pkgtools | |
parent | 0e790f73c882c2734373b5ccb22daeb7f33a7222 (diff) | |
download | pkgsrc-4597d80670e391df43162b8ee3b4357d8332d270.tar.gz |
Some bugfixes and improvements from both Tomasz Luchowski <zuntum@eik.pl>
and myself. Patch contributed in private mail.
Diffstat (limited to 'pkgtools')
-rwxr-xr-x | pkgtools/pkgdiff/files/pkgvi | 42 | ||||
-rw-r--r-- | pkgtools/pkgdiff/files/pkgvi.1 | 12 |
2 files changed, 24 insertions, 30 deletions
diff --git a/pkgtools/pkgdiff/files/pkgvi b/pkgtools/pkgdiff/files/pkgvi index d699ec848c2..57a884e25c7 100755 --- a/pkgtools/pkgdiff/files/pkgvi +++ b/pkgtools/pkgdiff/files/pkgvi @@ -1,5 +1,5 @@ #!/bin/sh -# $NetBSD: pkgvi,v 1.2 2001/01/18 15:40:23 jlam Exp $ +# $NetBSD: pkgvi,v 1.3 2001/01/18 17:04:21 hubertf Exp $ # # Copyright (c) 2001 Tomasz Luchowski. All rights reserved. # @@ -31,19 +31,6 @@ # SUCH DAMAGE. # -# -# Usage: pkgvi file -# -# The pkgvi utility runs user's favourite editor (it uses $PKG_EDITOR if -# defined, then it looks for $EDITOR, if none is defined, it uses vi) on -# copy of specified file. If no changes are made in the editor, nothing -# happens, else original file is stored as $filename.orig, and modified -# file is saved as $filename. If it founds $filename.orig, it behaves as -# normal editor. -# -# - Tomasz Luchowski <zuntum@eik.pl> -# - if [ "$PKGEDITOR" != "" ]; then editor="$PKGEDITOR" elif [ "$EDITOR" != "" ]; then @@ -72,28 +59,33 @@ fi if [ -f $file.orig ] then $editor $file - echo "$progname: Backup already exists, for a diff type:" + echo "$progname: Backup already exists. For a diff type:" echo "pkgdiff $file" exit 0 fi tmp="$file.$$" -cp $file $tmp +cp "$file" "$tmp" + +if [ $? -ne 0 ]; then + echo "$progname: unable to create temporary file" + exit 1 +fi -$editor $tmp +$editor "$tmp" -if cmp $file $tmp 2>&1 >/dev/null +if cmp "$file" "$tmp" 2>&1 >/dev/null then - echo File unchanged. + echo "$progname: File unchanged." else - mv $file $file.orig - mv $tmp $file - echo $progname: File was modified. For a diff, type: - echo pkgdiff $file + mv "$file" "$file.orig" + mv "$tmp" "$file" + echo "$progname: File was modified. For a diff, type:" + echo "pkgdiff $file" fi -if [ -f $tmp ] +if [ -f "$tmp" ] then - rm $tmp + rm "$tmp" fi diff --git a/pkgtools/pkgdiff/files/pkgvi.1 b/pkgtools/pkgdiff/files/pkgvi.1 index 299fa117f24..06f0eb14c4b 100644 --- a/pkgtools/pkgdiff/files/pkgvi.1 +++ b/pkgtools/pkgdiff/files/pkgvi.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: pkgvi.1,v 1.1 2001/01/17 23:16:46 hubertf Exp $ +.\" $NetBSD: pkgvi.1,v 1.2 2001/01/18 17:04:21 hubertf Exp $ .\" .\" Copyright (c) 2001 Tomasz Luchowski. All rights reserved. .\" @@ -35,7 +35,7 @@ .Os .Sh NAME .Nm pkgvi -.Nd run editor and make backup if file is modified +.Nd run editor and make backup if file is necessary .Sh SYNOPSIS .Nm .Ar file @@ -55,11 +55,13 @@ If finds .Pa filename.orig , it behaves as normal editor and changes are only made to -.Pa filename . +.Pa filename , +not affecting +.Pa filename.orig . .Sh ENVIRONMENT .Nm -uses $PKG_EDITOR if defined, then it looks for $EDITOR, -and if none is defined, it uses +uses $PKGEDITOR if defined, then it looks for $EDITOR, +if neither is defined, it uses .Xr vi 1 . .Pp .Sh SEE ALSO |