home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / src / perl / makedir.SH < prev    next >
Text File  |  1992-04-11  |  1KB  |  73 lines

  1. case $CONFIG in
  2. '')
  3.     if test ! -f config.sh; then
  4.     ln ../config.sh . || \
  5.     ln ../../config.sh . || \
  6.     ln ../../../config.sh . || \
  7.     (echo "Can't find config.sh."; exit 1)
  8.     fi 2>/dev/null
  9.     . ./config.sh
  10.     ;;
  11. esac
  12. case "$0" in
  13. */*) cd `expr X$0 : 'X\(.*\)/'` ;;
  14. esac
  15. echo "Extracting makedir (with variable substitutions)"
  16. $spitshell >makedir <<!GROK!THIS!
  17. $startsh
  18. # $Header: makedir.SH,v 4.0 91/03/20 01:27:13 lwall Locked $
  19. # $Log:    makedir.SH,v $
  20. # Revision 4.0  91/03/20  01:27:13  lwall
  21. # 4.0 baseline.
  22.  
  23. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  24.  
  25. case \$# in
  26.   0)
  27.     $echo "makedir pathname filenameflag"
  28.     exit 1
  29.     ;;
  30. esac
  31.  
  32. : guarantee one slash before 1st component
  33. case \$1 in
  34.   /*) ;;
  35.   *)  set ./\$1 \$2 ;;
  36. esac
  37.  
  38. : strip last component if it is to be a filename
  39. case X\$2 in
  40.   X1) set \`$echo \$1 | $sed 's:\(.*\)/[^/]*\$:\1:'\` ;;
  41.   *)  set \$1 ;;
  42. esac
  43.  
  44. : return reasonable status if nothing to be created
  45. if $test -d "\$1" ; then
  46.     exit 0
  47. fi
  48.  
  49. list=''
  50. while true ; do
  51.     case \$1 in
  52.     */*)
  53.     list="\$1 \$list"
  54.     set \`echo \$1 | $sed 's:\(.*\)/:\1 :'\`
  55.     ;;
  56.     *)
  57.     break
  58.     ;;
  59.     esac
  60. done
  61.  
  62. set \$list
  63.  
  64. for dir do
  65.     $mkdir \$dir >/dev/null 2>&1
  66. done
  67. !GROK!THIS!
  68. $eunicefix makedir
  69. chmod +x makedir
  70.