Annotation of coherent/b/STREAMS/conf/bin/cohtune, revision 1.1.1.1

1.1       root        1: # cohtune - change a system initializer.
                      2: 
                      3: CMD=$0
                      4: ARGS=$*
                      5: 
                      6: CONF=${CONF-/etc/conf}
                      7: 
                      8: usage() {
                      9:        echo "Usage: [CONF=conf-dir] $CMD device [ tag new-text ] ..."
                     10:        echo "  Modify Space.c for the given device."
                     11:        echo "  Replace the line containing tag (not in comments) by new-text."
                     12:        echo "  Fail if there is not a unique line matching tag."
                     13:        exit 1
                     14: }
                     15: 
                     16: # tagline(file, tag) reports the line number in file which contains tag
                     17: 
                     18: tagline() {
                     19: 
                     20:        # LNO is list of matching line numbers
                     21:        LNO=`/bin/cgrep -n $2 < $1 | /bin/sed -e "s/:.*//" \
                     22:          -e "s/^[      ]*//"`
                     23: 
                     24:        # LCOUNT is number of matching line numbers
                     25:        LCOUNT=`/bin/echo $LNO | wc -w`
                     26: 
                     27:        if [ $LCOUNT -ne 1 ]; then
                     28:                echo "$CMD $ARGS:  Found $LCOUNT matches for $TAG, wanted 1."
                     29:                exit 1
                     30:        fi
                     31: }
                     32: 
                     33: # Need at lease three args.
                     34: if  [ $# -lt 3 ]
                     35: then
                     36:        usage
                     37: fi
                     38: 
                     39: DEVICE=$1
                     40: 
                     41: SPACE_FILE=$CONF/$DEVICE/Space.c
                     42: 
                     43: # Need conf/device/Space.c file.
                     44: if [ ! -f $SPACE_FILE ]
                     45: then
                     46:        echo "Can't find $SPACE_FILE"
                     47:        exit 1
                     48: fi
                     49: 
                     50: shift
                     51: while [ $# -gt 1 ]
                     52: do
                     53:        TAG=$1
                     54:        shift
                     55:        tagline $SPACE_FILE $TAG
                     56:        NEW_TEXT=$1
                     57:        shift
                     58: 
                     59: # Do replacement.
                     60: 
                     61: /bin/ed - +v $SPACE_FILE <<_EOF
                     62: $LNO
                     63: c
                     64: $NEW_TEXT
                     65: .
                     66: p
                     67: wq
                     68: _EOF
                     69: 
                     70: done

unix.superglobalmegacorp.com

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