home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vile-src.zip / vile-8.1 / install.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1994-07-11  |  2KB  |  121 lines

  1. #!/bin/sh
  2.  
  3. #
  4. # install - install a program, script, or datafile
  5. # This comes from X11R5; it is not part of GNU.
  6. #
  7. # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
  8. #
  9. # This script is compatible with the BSD install script, but was written
  10. # from scratch.
  11. #
  12. # $Header: /usr2/foxharp/src/pgf/vile/RCS/install.sh,v 1.2 1994/07/11 22:56:20 pgf Exp $
  13.  
  14.  
  15. # set DOITPROG to echo to test this script
  16.  
  17. # Don't use :- since 4.3BSD and earlier shells don't like it.
  18. doit="${DOITPROG-}"
  19.  
  20.  
  21. # put in absolute paths if you don't have them in your path; or use env. vars.
  22.  
  23. mvprog="${MVPROG-mv}"
  24. cpprog="${CPPROG-cp}"
  25. chmodprog="${CHMODPROG-chmod}"
  26. chownprog="${CHOWNPROG-chown}"
  27. chgrpprog="${CHGRPPROG-chgrp}"
  28. stripprog="${STRIPPROG-strip}"
  29. rmprog="${RMPROG-rm}"
  30.  
  31. instcmd="$mvprog"
  32. chmodcmd=""
  33. chowncmd=""
  34. chgrpcmd=""
  35. stripcmd=""
  36. rmcmd="$rmprog -f"
  37. mvcmd="$mvprog"
  38. src=""
  39. dst=""
  40.  
  41. while [ x"$1" != x ]; do
  42.     case $1 in
  43.     -c) instcmd="$cpprog"
  44.         shift
  45.         continue;;
  46.  
  47.     -m) chmodcmd="$chmodprog $2"
  48.         shift
  49.         shift
  50.         continue;;
  51.  
  52.     -o) chowncmd="$chownprog $2"
  53.         shift
  54.         shift
  55.         continue;;
  56.  
  57.     -g) chgrpcmd="$chgrpprog $2"
  58.         shift
  59.         shift
  60.         continue;;
  61.  
  62.     -s) stripcmd="$stripprog"
  63.         shift
  64.         continue;;
  65.  
  66.     *)  if [ x"$src" = x ]
  67.         then
  68.         src=$1
  69.         else
  70.         dst=$1
  71.         fi
  72.         shift
  73.         continue;;
  74.     esac
  75. done
  76.  
  77. if [ x"$src" = x ]
  78. then
  79.     echo "install:  no input file specified"
  80.     exit 1
  81. fi
  82.  
  83. if [ x"$dst" = x ]
  84. then
  85.     echo "install:  no destination specified"
  86.     exit 1
  87. fi
  88.  
  89.  
  90. # If destination is a directory, append the input filename; if your system
  91. # does not like double slashes in filenames, you may need to add some logic
  92.  
  93. if [ -d $dst ]
  94. then
  95.     dst="$dst"/`basename $src`
  96. fi
  97.  
  98. # Make a temp file name in the proper directory.
  99.  
  100. dstdir=`dirname $dst`
  101. dsttmp=$dstdir/#inst.$$#
  102.  
  103. # Move or copy the file name to the temp name
  104.  
  105. $doit $instcmd $src $dsttmp
  106.  
  107. # and set any options; do chmod last to preserve setuid bits
  108.  
  109. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
  110. if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
  111. if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
  112. if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
  113.  
  114. # Now rename the file to the real destination.
  115.  
  116. $doit $rmcmd $dst
  117. $doit $mvcmd $dsttmp $dst
  118.  
  119.  
  120. exit 0
  121.