# example from page 278
#
# SHELL VERSION OF nohup COMMAND
#
trap '' HUP		# ignore hangup
command=$(whence "$1")
oldmask=$(umask)
umask u=rw,og=		# default mode for nohup.out
exec 0< /dev/null	# disconnect input
if	[[ -t 1 ]]	# redirect output if necessary
then	if	[[ -w . ]]
	then	print 'Sending output to nohup.out'
		exec >> nohup.out
	else	print "Sending output to $HOME/nohup.out"
		exec >> $HOME/nohup.out
	fi
fi
umask "$oldmask"
if	[[ -t 2 ]]	# direct unit 2 to a file
then	exec 2>&1
fi
# run the command
case $command in
*/*)	exec "$@"
	;;
time)	eval "$@"
	;;
*)	"$@"
	;;
esac
