home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / usr / bin / install < prev    next >
Encoding:
Text File  |  1992-07-21  |  3.6 KB  |  222 lines

  1. #!/bin/csh -f
  2. #PROGRAM:install  PROJECT:sgcmds-28.3  DEVELOPER:root  BUILT:Tue Jul 21 13:20:38 WET 1992
  3. umask 022
  4. set path=($path /etc)
  5. set cmd="cp -p"
  6. set links
  7. set quick
  8. set symlink
  9. set link="ln"
  10. while (1)
  11.     switch ($1)
  12.     case -s:
  13.         set strip="strip"
  14.         shift
  15.         breaksw
  16.     case -sX:
  17.         set strip="strip -X"
  18.         shift
  19.         breaksw
  20.     case -sx:
  21.         set strip="strip -x"
  22.         shift
  23.         breaksw
  24.     case -sA:
  25.         set strip="strip -A"
  26.         shift
  27.         breaksw
  28.     case -sS:
  29.         set strip="strip -S"
  30.         shift
  31.         breaksw
  32.     case -sSd:
  33.         set strip="strip -S -d $2"
  34.         shift
  35.         shift
  36.         breaksw
  37.     case -sgg:
  38.         set strip="strip -gg"
  39.         shift
  40.         breaksw
  41.     case -sAn:
  42.         set strip="strip -A -n"
  43.         shift
  44.         breaksw
  45.     case -r:
  46.         set ranlib="ranlib"
  47.         shift
  48.         breaksw
  49.     case -q:
  50.         set quick="quick"
  51.         shift
  52.         breaksw
  53.     case -c:
  54.         set cmd="cp -p"
  55.         shift
  56.         breaksw
  57.     case -d:
  58.         set cmp="cmp"
  59.         shift
  60.         breaksw
  61.     case -v:
  62.         set vecho="echo"
  63.         shift
  64.         breaksw
  65.     case -m:
  66.         set chmod="chmod $2"
  67.         shift
  68.         shift
  69.         breaksw
  70.     case -o:
  71.         set chown="chown -f $2"
  72.         shift
  73.         shift
  74.         breaksw
  75.     case -g:
  76.         set chgrp="chgrp -f $2"
  77.         shift
  78.         shift
  79.         breaksw
  80.     case -xc:
  81.         set cmd="sed"
  82.         set comments='/^[     ]*#/d'
  83.         shift
  84.         breaksw
  85.     case -xs:
  86.         set cmd="sed"
  87.         set comments='/^[     ]*[#:]/d'
  88.         shift
  89.         breaksw
  90.     case -l:
  91.         set links="$links $2"
  92.         shift
  93.         shift
  94.         breaksw
  95.     case -u:
  96.         set unlink="rm -f"
  97.         shift
  98.         breaksw
  99.     case -V:    
  100.         set stamp="vers_string -f"
  101.         set link="symlink -r -f"
  102.         shift
  103.         breaksw
  104.     case -S:
  105.         set save=1
  106.         shift
  107.         breaksw
  108.     default:
  109.         break
  110.         breaksw
  111.     endsw
  112. end
  113. if ( $#argv < 2 ) then
  114.     echo "install: no destination specified"
  115.     exit(1)
  116. endif
  117. set dest=$argv[$#argv]
  118. if ( $#argv > 2 ) then
  119.     if ( ! -d $dest ) then
  120.         echo "usage: install f1 f2 or f1 f2 ... dir"
  121.         exit(1)
  122.     endif
  123. endif
  124. if (  $1 == $dest ||  $dest == .  ) then
  125.     echo "install: can't move $1 onto itself"
  126.     exit(1)
  127. endif
  128. foreach j ($argv)
  129.     if ( $j == $dest) break
  130.     if ( ! -f $j ) then
  131.         echo "install: can't open $j"
  132.         exit(1)
  133.     endif
  134.     if ( -d $dest ) then
  135.         set file=$des(Xp
  136.     else
  137.         set file=$dest
  138.     endif
  139.     if ( $?stamp ) then
  140.         set symlink=$file
  141.         set file=`$stamp $file`
  142.     endif
  143.     if ( "$cmd" == "sed" ) then
  144.         if ( -e $file && $?save ) then
  145.             rm -f $file.old
  146.             if ( ! { mv $file $file.old } ) exit(1)
  147.         endif
  148.         if ( $?unlink ) then
  149.             $unlink $file
  150.         endif
  151.         if ($?vecho) then
  152.             echo sed -e '<strip comments>' $j ">$file"
  153.         endif
  154.         sed -e '1s;^#\!;&;p' -e '2s;^#PROG;&;p' -e "$comments" $j >$file
  155.     else if ( $?cmp ) then
  156.         echo -n CMP $j $file
  157.         if ( { cmp -s $j $file } ) then
  158.             echo ';'
  159.         else
  160.             if ( -e $file && $?save ) then
  161.                 rm -f $file.old
  162.                 if ( ! { mv $file $file.old } ) exit(1)
  163.             endif
  164.             if ( $?unlink ) then
  165.                 $unlink $file
  166.             endif
  167.             echo " THEN" $cmd
  168.             if ( ! { $cmd $j $file } ) exit(1)
  169.         endif
  170.     else
  171.         if ( -e $file && $?save ) then
  172.             rm -f $file.old
  173.             if ( ! { mv $file $file.old } ) exit(1)
  174.         endif
  175.         if ( $?unlink ) then
  176.             $unlink $file
  177.         endif
  178.         if ($?vecho) then
  179.             echo $cmd $j $file
  180.         endif
  181.         if ( ! { $cmd $j $file } ) exit(1)
  182.     endif
  183.     if ( $?strip ) then
  184.         if ($?vecho) then
  185.             echo $strip $file
  186.         endif
  187.         if ( ! { $strip $file } ) exit(1)
  188.     endif
  189.     if ( $?ranlib ) then
  190.         if ($?vecho) then
  191.             echo $ranlib $file
  192.         endif
  193.         if ( ! { $ranlib $file } ) exit(1)
  194.     endif
  195.     if ( $?chmod ) then
  196.         if ($?vecho) then
  197.             echo $chmod $file
  198.         endif
  199.         if ( ! { $chmod $file } ) exit(1)
  200.     endif
  201.     if ( $?chown ) then
  202.         if ($?vecho) then
  203.             echo $chown $file
  204.         endif
  205.         if ( ! { $chown $file } ) exit(1)
  206.     endif
  207.     if ( $?chgrp ) then
  208.         if ($?vecho) then
  209.             echo $chgrp $file
  210.         endif
  211.         if ( ! { $chgrp $file } ) exit(1)
  212.     endif
  213. end
  214. foreach i ( $symlink $links )
  215.     if ($?vecho) then
  216.         echo $link $file $i
  217.     endif
  218.     rm -f $i
  219.     if ( ! { $link $file $i } ) exit(1)
  220. end
  221. exit(0)
  222.