Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

#!/bin/sh -
#
#	$NetBSD: virecover,v 1.4 2017/11/09 15:03:01 christos Exp $
#
#	@(#)recover.in	8.8 (Berkeley) 10/10/96
#
# Script to recover nvi edit sessions.

RECDIR="/var/tmp/vi.recover"
SENDMAIL="/usr/sbin/sendmail"

# Check editor backup files.
for i in $RECDIR/vi.*; do

	case "$i" in
	$RECDIR/vi.\*) continue;;
	esac

	# Only test files that are readable.
	if [ ! -f "$i" ] || [ ! -r "$i" ]; then
		continue
	fi

	# Unmodified nvi editor backup files either have the
	# execute bit set or are zero length.  Delete them.
	if [ -x "$i" ] || [ ! -s "$i" ]; then
		rm -f "$i"
	fi
done

# It is possible to get incomplete recovery files, if the editor crashes
# at the right time.
for i in $RECDIR/recover.*; do

	case "$i" in
	$RECDIR/recover.\*) continue;;
	esac

	# Only test plain files that are readable.
	if [ ! -f "$i" ] || [ ! -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 [ -n "$recfile" ] && [ -s "$recfile" ]; then
		$SENDMAIL -t < "$i"
	else
		rm -f "$i"
	fi
done