You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.4 KiB

26 years ago
  1. # WARNING -- first line intentionally left blank for sh/csh/ksh
  2. # compatibility. Do not remove it! FNF, UniSoft Systems.
  3. #
  4. # Usage is:
  5. # install <from> <to>
  6. #
  7. # The file <to> is replaced with the file <from>, after first
  8. # moving <to> to a backup file. The backup file name is created
  9. # by prepending the filename (after removing any leading pathname
  10. # components) with "OLD".
  11. #
  12. # This script is currently not real robust in the face of signals
  13. # or permission problems. It also does not do (by intention) all
  14. # the things that the System V or BSD install scripts try to do
  15. #
  16. if [ $# -ne 2 ]
  17. then
  18. echo "usage: $0 <from> <to>"
  19. exit 1
  20. fi
  21. # Now extract the dirname and basename components. Unfortunately, BSD does
  22. # not have dirname, so we do it the hard way.
  23. fd=`expr $1'/' : '\(/\)[^/]*/$' \| $1'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .`
  24. ff=`basename $1`
  25. td=`expr $2'/' : '\(/\)[^/]*/$' \| $2'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .`
  26. tf=`basename $2`
  27. # Now test to make sure that they are not the same files.
  28. if [ $fd/$ff = $td/$tf ]
  29. then
  30. echo "install: input and output are same files"
  31. exit 2
  32. fi
  33. # Save a copy of the "to" file as a backup.
  34. if test -f $td/$tf
  35. then
  36. if test -f $td/OLD$tf
  37. then
  38. rm -f $td/OLD$tf
  39. fi
  40. mv $td/$tf $td/OLD$tf
  41. if [ $? != 0 ]
  42. then
  43. exit 3
  44. fi
  45. fi
  46. # Now do the copy and return appropriate status
  47. cp $fd/$ff $td/$tf
  48. if [ $? != 0 ]
  49. then
  50. exit 4
  51. else
  52. exit 0
  53. fi