Annotation of researchv10no/cmd/uucp/unused/Cpset, revision 1.1.1.1

1.1       root        1: #!/bin/sh
                      2: #      @(#)Cpset       1.3
                      3: 
                      4: 
                      5: # This shell simulates the action of the spset command that
                      6: # is available on system V systems.
                      7: #  It only does the part required for my makefile!
                      8: #
                      9: USAGE="usage: Cpset [-o] from-file to-file  mode  owner group"
                     10: #
                     11: # It will copy the file, change the mode, owner and
                     12: # group if specified.  If -o is used, an existing file is moved
                     13: # to OLDfile.
                     14: 
                     15: OLD=
                     16: MODE=
                     17: OWNER=
                     18: GROUP=
                     19: FILE=
                     20: TO=
                     21: 
                     22: while [ $# -gt 0 ]
                     23: do
                     24:        case $1 in
                     25:        -o)     OLD="OLD"
                     26:                shift
                     27:                ;;
                     28:        *)      break
                     29:                ;;
                     30:        esac
                     31: done
                     32: 
                     33: if [ $# -lt 2 ]; then
                     34:        echo $USAGE
                     35:        exit 1
                     36: fi
                     37: 
                     38: FILE=$1
                     39: TO=$2
                     40: MODE=$3
                     41: OWNER=$4
                     42: GROUP=$5
                     43: 
                     44: BASE=`basename $TO`
                     45: TODIR=` echo $TO | sed "s/${BASE}\$//"`
                     46: if [ -n "$OLD" -a -f $TO ]; then
                     47:        rm -f $TODIR/OLD$BASE
                     48:        echo Cpset: mv $TO $TODIR/OLD$BASE
                     49:        mv $TO $TODIR/OLD$BASE
                     50: fi
                     51: 
                     52: rm -f $TO
                     53: echo Cpset: cp $FILE $TO
                     54: cp $FILE $TO
                     55: 
                     56: if [ -n "$GROUP" ]; then
                     57:        echo Cpset: chgrp $GROUP $TO
                     58:        chgrp $GROUP $TO
                     59: fi
                     60: 
                     61: if [ -n "$OWNER" ]; then
                     62:        echo Cpset: chown $OWNER $TO
                     63:        chown $OWNER $TO
                     64: fi
                     65: 
                     66: if [ -n "$MODE" ]; then
                     67:        echo Cpset: chmod $MODE $TO
                     68:        chmod $MODE $TO
                     69: fi
                     70: 
                     71: ls -l $TO

unix.superglobalmegacorp.com

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