Annotation of coherent/a/usr/man/COHERENT/trap, revision 1.1

1.1     ! root        1: 
        !             2: 
        !             3: trap                         Command                         trap
        !             4: 
        !             5: 
        !             6: 
        !             7: 
        !             8: Execute command on receipt of signal
        !             9: 
        !            10: ttrraapp [_c_o_m_m_a_n_d] [_n ...]
        !            11: 
        !            12: trap instructs the shell sh to execute the given command when the
        !            13: shell receives signal n or any other signal in the optional list.
        !            14: If the  command is omitted, trap resets traps  for the given sig-
        !            15: nals to  the original  values.  If the  command is a  null string
        !            16: (i.e., a  string that consists  only of one  null character), the
        !            17: shell ignores  the given  signals.  If n  is zero, the  shell ex-
        !            18: ecutes the  specified command when it exits.   When it is invoked
        !            19: with no arguments, trap  prints the signal number and command for
        !            20: each signal on which a trap is set.
        !            21: 
        !            22: The shell executes trap directly.
        !            23: 
        !            24: ***** Example *****
        !            25: 
        !            26: The  following example  takes two  files  and outputs  only those
        !            27: lines which are the same.
        !            28: 
        !            29: 
        !            30: # If input only one file-name then simply "cat".
        !            31: if [ $# = 1 ]; then
        !            32:         cat $1
        !            33:         exit 0
        !            34: 
        !            35: 
        !            36: 
        !            37: # If input two file-names - Ok, else "Usage".
        !            38: else
        !            39:         if [ $# != 2 ]; then
        !            40:                 echo "Usage: cmn file1 [file2]"
        !            41:                 exit 1
        !            42:         fi
        !            43: fi
        !            44: 
        !            45: 
        !            46: 
        !            47: # TMP is original name of temporary file (/tmp/temp_(pid)
        !            48: TMP=/tmp/temp_$$
        !            49: 
        !            50: 
        !            51: 
        !            52: # Temporary file has to be removed
        !            53: trap 'rm $TMP; exit 1' 1 2 9
        !            54: 
        !            55: 
        !            56: 
        !            57: # Difference between "file1" and "difference between file1 and file2"
        !            58: # is the common strings "file1" and "file2"
        !            59: # The strings that are in "file1" and absent in "file2" print in TMP.
        !            60: diff $1 $2 | sed -n -e "s/^< //p" > $TMP
        !            61: 
        !            62: 
        !            63: 
        !            64: COHERENT Lexicon                                           Page 1
        !            65: 
        !            66: 
        !            67: 
        !            68: 
        !            69: trap                         Command                         trap
        !            70: 
        !            71: 
        !            72: 
        !            73: 
        !            74: 
        !            75: # The strings that are in "file1" and absent in TMP print in stdout.
        !            76: diff $1 $TMP | sed -n -e "s/^< //p"
        !            77: 
        !            78: 
        !            79: 
        !            80: # Remove temporary file
        !            81: rm $TMP
        !            82: 
        !            83: 
        !            84: ***** See Also *****
        !            85: 
        !            86: commands, sh, signal
        !            87: 
        !            88: 
        !            89: 
        !            90: 
        !            91: 
        !            92: 
        !            93: 
        !            94: 
        !            95: 
        !            96: 
        !            97: 
        !            98: 
        !            99: 
        !           100: 
        !           101: 
        !           102: 
        !           103: 
        !           104: 
        !           105: 
        !           106: 
        !           107: 
        !           108: 
        !           109: 
        !           110: 
        !           111: 
        !           112: 
        !           113: 
        !           114: 
        !           115: 
        !           116: 
        !           117: 
        !           118: 
        !           119: 
        !           120: 
        !           121: 
        !           122: 
        !           123: 
        !           124: 
        !           125: 
        !           126: 
        !           127: 
        !           128: 
        !           129: 
        !           130: COHERENT Lexicon                                           Page 2
        !           131: 
        !           132: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.