Advanced Bash− Scripting Guide An in− depth exploration of the art of shell scripting Me

源代码在线查看: trap.err

软件大小: 63 K
上传用户: xiaoy2000
关键词: 8722 exploration Scripting scripting
下载地址: 免注册下载 普通下载 VIP

相关代码

				#!/bin/ksh				# Script name: trap.err				# Example 10.131								# This trap checks for any command that exits with a non-zero 					# status and then prints the message.				trap 'print "You gave me a non-integer. Try again. "' ERR				typeset -i number   #Assignment to number must be integer				while true				do				    print -n "Enter an integer. " 				    read -r number 2> /dev/null				    if (( $? == 0 ))   # Was an integer read in? 				    then               # Was the exit status zero?					break 				    fi				done				trap - ERR   # Unset pseudo trap for ERR				n=$number												if grep ZOMBIE /etc/passwd > /dev/null 2>&1				then					:  				else				    print "\$n is $n. So long"				fi							

相关资源