home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1879 / cd.com next >
Text File  |  1990-12-28  |  643b  |  25 lines

  1. $! cd.com - simulate Un*x 'cd' command
  2. $
  3. $ if p1 .eqs. "" then p1 = f$logical("sys$login")
  4. $
  5. $! translate disk:[dir1.dir2.dirN] to disk:[dir1.dir2.-]dirN.dir
  6. $
  7. $ dir = f$parse(p1,,,"DIRECTORY") - "[" - "]"
  8. $l1:
  9. $  n = f$locate(".", dir)
  10. $  if n .ge. f$length(dir) then goto l2
  11. $  dir = f$extract(n + 1, 999, dir)
  12. $  goto l1
  13. $l2:
  14. $ dir = p1 - "]" + ".-]" + dir + ".dir"
  15. $
  16. $ if f$search(dir) .nes. "" then goto OK        ! look for directory
  17. $ if f$trnlog(p1 - ":") .nes. "" then goto OK        ! try logical name
  18. $  write sys$output "Directory ", p1, " does not exist"
  19. $  exit
  20. $
  21. $OK:
  22. $ set def 'p1
  23. $ if f$type(pwd) .eqs. "" then pwd :== show default
  24. $ pwd
  25.