#!/bin/bashfunction trapper () { echo "In trapper" trap 'echo "Caught in a trap!"' INT # Once set, this trap affects the entire script. Anytime # ^C is entered, the script will ignore it.}while :do echo "In the main script" trapper echo "Still in ma...【阅读全文】
#!/bin/kshfunction trapper { print "In trapper" trap 'print "Caught in a trap!"' INT print "Got here." sleep 25}while :do print "In the main script" trapper # Call the function print "Still in main" sleep 5 print "Bye"do...【阅读全文】
#!/bin/shtrapper () { echo "In trapper" trap 'echo "Caught in a trap!"' 2 # Once set, this trap affects the entire script. Anytime # ^C is entered, the script will ignore it.}while :do echo "In the main script" trapper echo "Still in main"&nb...【阅读全文】
#!/bin/sh# Program opts2# Using getopts -- Second try --while getopts xy options 2> /dev/nulldo case $options in x) echo "you entered -x as an option";; y) echo "you entered -y as an option";; \?) echo "Only -x and -y are valid options" 1>&2;; esacdone...【阅读全文】
#!/bin/sh# Program opts1# Using getopts -- First try --while getopts xy optionsdo case $options in x) echo "you entered -x as an option";; y) echo "you entered -y as an option";; esacdone【阅读全文】
from nt import *def walk(top, topdown=True, onerror=None): from os.path import join, isdir, islink # We may not have read permission for top, in which case we can't # get a list of the files the directory ...【阅读全文】