editentry

来自「ftam等标准协议服务器和客户端的源代码。」· 代码 · 共 102 行

TXT
102
字号
#!/bin/sh#if [ $# != "1" ]; then    echo usage: editentry filename    exit 1fiF=Twhile test -z "$EDITOR"do    if [ $F = "T" ]; then	echo 'You do not have the shell variable $EDITOR set.'	F=F    fi    echo ''    echo -n 'Enter the name of an editor: '    read EDITOR rubbish    if [ ! -x "$EDITOR" ]; then	IFSS="$IFS"	IFS=: F="$EDITOR"	EDITOR=	for D in $PATH; do	    if [ -x "$D/$F" ]; then		EDITOR="$D/$F"		break	    fi	done	if [ -z "$EDITOR" ]; then	    echo "$F not found, please try again..."	fi	IFS="$IFSS"    fidonecp $1 $1.tmpE=Twhile truedo    if [ $E = "T" ]; then	if $EDITOR $1; then	    if cmp -s $1 $1.tmp; then		mess="No changes to draft entry - shall I continue? "	    else		mess="Are you sure you want to make these changes? "	    fi		else	    echo 'Edit aborted...'	    rm -f $1.tmp	    exit 1	fi    fi    echo -n "$mess"    read YN rubbish    case "$YN" in	y|yes|Y|YES) 	    rm -f $1.tmp	    exit 0	    ;;	n|no|N|NO)	    mv $1.tmp $1	    exit 1	    ;;	e|edit|E|EDIT)	    cp $1 $1.tmp	    if [ ! -z "$rubbish" ]	    then		EDITOR="$rubbish"	    fi	    E=T	    ;;	u|undo|U|UNDO)	    cp $1.tmp $1	    E=T	    ;;	*)			    case "$YN" in		\?|""|h|help|H|HELP)		    mess='Options are:'		    ;;		*)		    mess="\"$YN\" not understood -- use one of:"		    ;;	    esac	    echo "$mess"	    echo '     yes - to commit'	    echo '      no - to abort'	    echo '    edit - to continue editing'	    echo '    undo - to undo last edit and edit some more'	    mess='Try again: '	    E=F	    ;;    esacdone

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?