Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/nvi/usr.bin/recover - don't use command substit...
details: https://anonhg.NetBSD.org/src/rev/3ed21d789d3d
branches: trunk
changeset: 357275:3ed21d789d3d
user: christos <christos%NetBSD.org@localhost>
date: Sat Nov 04 05:43:18 2017 +0000
description:
- don't use command substitution to glob a pattern into a list of filenames;
it is less efficient than doing it directly and does not handle whitespace
in filenames properly.
- change test to [
- quote variables
diffstat:
external/bsd/nvi/usr.bin/recover/virecover | 60 +++++++++++++----------------
1 files changed, 27 insertions(+), 33 deletions(-)
diffs (78 lines):
diff -r 52227baf5dcc -r 3ed21d789d3d external/bsd/nvi/usr.bin/recover/virecover
--- a/external/bsd/nvi/usr.bin/recover/virecover Sat Nov 04 03:26:41 2017 +0000
+++ b/external/bsd/nvi/usr.bin/recover/virecover Sat Nov 04 05:43:18 2017 +0000
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $NetBSD: virecover,v 1.1 2013/11/22 16:00:45 christos Exp $
+# $NetBSD: virecover,v 1.2 2017/11/04 05:43:18 christos Exp $
#
# @(#)recover.in 8.8 (Berkeley) 10/10/96
#
@@ -10,40 +10,34 @@
SENDMAIL="/usr/sbin/sendmail"
# Check editor backup files.
-vibackup=`echo $RECDIR/vi.*`
-if [ "$vibackup" != "$RECDIR/vi.*" ]; then
- for i in $vibackup; do
- # Only test files that are readable.
- if test ! -f $i || test ! -r $i; then
- continue
- fi
+for i in $RECDIR/vi.*; do
+ # Only test files that are readable.
+ if [ \( ! -f "$i" \) -o \( ! -r "$i" \) ]; then
+ continue
+ fi
- # Unmodified nvi editor backup files either have the
- # execute bit set or are zero length. Delete them.
- if test -x $i -o ! -s $i; then
- rm $i
- fi
- done
-fi
+ # Unmodified nvi editor backup files either have the
+ # execute bit set or are zero length. Delete them.
+ if [ \( -x "$i" \) -o \( -z "$i" \) ]; then
+ rm -f "$i"
+ fi
+done
# It is possible to get incomplete recovery files, if the editor crashes
# at the right time.
-virecovery=`echo $RECDIR/recover.*`
-if [ "$virecovery" != "$RECDIR/recover.*" ]; then
- for i in $virecovery; do
- # Only test files that are readable.
- if test ! -r $i; then
- continue
- fi
+for i in $RECDIR/recover.*; do
+ # Only test files that are readable.
+ if [ ! -r "$i" ]; then
+ continue
+ fi
- # Delete any recovery files that are zero length, corrupted,
- # or that have no corresponding backup file. Else send mail
- # to the user.
- recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
- if test -n "$recfile" -a -s "$recfile"; then
- $SENDMAIL -t < $i
- else
- rm $i
- fi
- done
-fi
+ # Delete any recovery files that are zero length, corrupted,
+ # or that have no corresponding backup file. Else send mail
+ # to the user.
+ recfile=$(awk '/^X-vi-recover-path:/{print $2}' < "$i")
+ if [ \( -n "$recfile" \) -a \( -s "$recfile" \); then
+ $SENDMAIL -t < "$i"
+ else
+ rm -f "$i"
+ fi
+done
Home |
Main Index |
Thread Index |
Old Index