home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d8xx / d811 / bsh.lha / bsh / mkpath < prev    next >
Text File  |  1993-02-14  |  659b  |  29 lines

  1. # mkpath path
  2. if !?argv[1]
  3.     echo >&2 usage: mkpath pathname
  4.     return 10
  5. endif
  6. local k i=0 tpath=argv[1] lpath[32]
  7. while strlen(tpath) > 0
  8.     lpath[i++] = tpath
  9.     if (k = rindex(tpath,'/')) >= 0
  10.     tpath = left(tpath,k)
  11.     else
  12.     tpath = ""
  13.     endif
  14. endwhile
  15.  
  16. while i-- > 0
  17.     if -d "$lpath[$i]"
  18.     continue
  19.     elseif -f "$lpath[$i]"
  20.     echo object already exists: $1
  21.     return 100
  22.     endif
  23.     mkdir $lpath[$i]
  24. endwhile
  25. # Mkpath is presented as is; no warrantee is either expressed or implied
  26. # as to it's suitability to any purpose whatsoever.  You assume all the
  27. # risk for all damage, even if caused by a defect in the software,
  28. # no matter how awful.
  29.