Annotation of 43BSDReno/pgrm/lorder/lorder.sh, revision 1.1

1.1     ! root        1: #!/bin/sh -
        !             2: #
        !             3: # Copyright (c) 1990 The Regents of the University of California.
        !             4: # All rights reserved.
        !             5: #
        !             6: # Redistribution and use in source and binary forms are permitted
        !             7: # provided that the above copyright notice and this paragraph are
        !             8: # duplicated in all such forms and that any documentation,
        !             9: # advertising materials, and other materials related to such
        !            10: # distribution and use acknowledge that the software was developed
        !            11: # by the University of California, Berkeley.  The name of the
        !            12: # University may not be used to endorse or promote products derived
        !            13: # from this software without specific prior written permission.
        !            14: # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            15: # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            16: # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            17: #
        !            18: #      @(#)lorder.sh   5.2 (Berkeley) 3/20/90
        !            19: #
        !            20: PATH=/bin:/usr/bin
        !            21: export PATH
        !            22: 
        !            23: # only one argument is a special case, just output the name twice
        !            24: case $# in
        !            25:        0)
        !            26:                echo "usage: lorder file ...";
        !            27:                exit ;;
        !            28:        1)
        !            29:                echo $1 $1;
        !            30:                exit ;;
        !            31: esac
        !            32: 
        !            33: # temporary files
        !            34: R=/tmp/_reference_$$
        !            35: S=/tmp/_symbol_$$
        !            36: 
        !            37: # remove temporary files on HUP, INT, QUIT, PIPE, TERM
        !            38: trap "rm -f $R $S; exit 1" 1 2 3 13 15
        !            39: 
        !            40: # if the line ends in a colon, assume it's the first occurrence of a new
        !            41: # object file.  Echo it twice, just to make sure it gets into the output.
        !            42: #
        !            43: # if the line has " T " or " D " it's a globally defined symbol, put it
        !            44: # into the symbol file.
        !            45: #
        !            46: # if the line has " U " it's a globally undefined symbol, put it into
        !            47: # the reference file.
        !            48: nm -go $* | sed "
        !            49:        /:$/ {
        !            50:                s/://
        !            51:                s/.*/& &/
        !            52:                p
        !            53:                d
        !            54:        }
        !            55:        / [TD] / {
        !            56:                s/:.* [TD]//
        !            57:                w $S
        !            58:                d
        !            59:        }
        !            60:        / U / {
        !            61:                s/:.* U//
        !            62:                w $R
        !            63:        }
        !            64:        d
        !            65: "
        !            66: 
        !            67: # sort symbols and references on the first field (the symbol)
        !            68: # join on that field, and print out the file names.
        !            69: sort +1 $R -o $R
        !            70: sort +1 $S -o $S
        !            71: join -j 2 -o 1.1 2.1 $R $S
        !            72: rm -f $R $S

unix.superglobalmegacorp.com

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