home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / armlinux / alpha / PARTITIONS / USR_GZ / usr / lib / trn / makedir < prev    next >
Encoding:
Text File  |  1995-05-14  |  905 b   |  53 lines

  1. #!/bin/sh
  2. # $Id: makedir.SH,v 2.11 90/09/17 17:03:55 hokey Exp Locker: hokey $
  3. # $Log:    makedir.SH,v $
  4. # Revision 2.11  90/09/17  17:03:55  hokey
  5. # 2.11 alpha baseline
  6.  
  7. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  8.  
  9. case $# in
  10.   0)
  11.     /bin/echo "makedir pathname filenameflag"
  12.     exit 1
  13.     ;;
  14. esac
  15.  
  16. : guarantee one slash before 1st component
  17. case $1 in
  18.   /*) ;;
  19.   *)  set ./$1 $2 ;;
  20. esac
  21.  
  22. : strip last component if it is to be a filename
  23. case X$2 in
  24.   X1) set `/bin/echo $1 | /usr/bin/sed 's:\(.*\)/[^/]*$:\1:'` ;;
  25.   *)  set $1 ;;
  26. esac
  27.  
  28. : return reasonable status if nothing to be created
  29. if test -d "$1" ; then
  30.     exit 0
  31. fi
  32.  
  33. list=''
  34. while : ; do
  35.     case $1 in
  36.     */*)
  37.     list="$1 $list"
  38.     set `echo $1 | /usr/bin/sed 's:\(.*\)/:\1 :'`
  39.     ;;
  40.     *)
  41.     break
  42.     ;;
  43.     esac
  44. done
  45.  
  46. set $list
  47.  
  48. for dir do
  49.     /bin/mkdir $dir >/dev/null 2>&1
  50. done
  51.