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

  1. if #argv != 3
  2.     echo >&2 usage $0 fromdir todir
  3.     return 10
  4. endif
  5. local from=argv[1] to=argv[2] fromdev todev
  6.  
  7. if index(from,":") < 0        # no absolute path for FROM?
  8.     fromdev = devname(cwd)
  9. else
  10.     fromdev = devname(from)
  11. endif
  12. if index(to,":") < 0        # no absolute path for TO?
  13.     todev = devname(cwd)
  14. else
  15.     todev = devname(to)
  16. endif
  17. if fromdev==todev        # FROM & TO on same device?
  18.     mv "$from" "$to"        # if so, just rename the dir
  19.     return status
  20. endif
  21. if -e "$to"
  22.     local tail=from j
  23.     if (j=rindex(from,'/'))>=0
  24.     tail=right(from,strlen(from)-j-1)
  25.     elseif (j=index(from,':'))>=0
  26.     if j<strlen(from)-1
  27.         tail=right(from,strlen(from)-j-1)
  28.     endif
  29.     endif
  30.     if right(to,1)==':'
  31.     to=cat(to,tail)
  32.     else
  33.     to=cat(to,'/',tail)
  34.     endif
  35.     if -e "$to"         # if TO already exists
  36.     echo $0: $to already exists
  37.     return 10
  38.     endif
  39. endif
  40. mkpath "$to"
  41. if status > 5
  42.     return status
  43. endif
  44. cp -cur "$from" "$to"
  45. if status > 5            # any problems with the copy?
  46.     return status
  47. endif
  48. rm -r $from
  49. # Mvdir is presented as is; no warrantee is either expressed or implied
  50. # as to it's suitability to any purpose whatsoever.  You assume all the
  51. # risk for all damage, even if caused by a defect in the software,
  52. # no matter how awful.
  53.