daemon@ucbvax.UUCP (09/15/83)
>From GEOFF5@SRI-CSL Thu Sep 15 03:48:39 1983
First, I no longer have the original letters on the subject, and my list of
DLs in out of date, so if this is not a good or the best address, someone tell
me !
Below is my cd.com . It does not try to deal with device names, and is
simply a hack to act like unix 99.9% of the times I type cd, which it
does since I rattle around on the same disk... I suppose an obvious addition
would be to recognize / as root so that you can say cd /clark/bin instead of
the kludgy cd [clark] and cd bin or cd [clark]/bin, but it has not bothered
me sufficiently yet.
$ if p1 .nes. "" then goto l1
$ p1 := sys$login
$ doit:
$ set def 'p1'
$ done:
$ exit
$ l1:
$ if "''f$extract(0,4,p1)'" .eqs. "SYS$" then goto doit
$ if "''f$extract(0,5,p1)'" .eqs. "USER$" then goto doit
$
$ ! From here it could be an arbitrary path...
$
$ dorest:
$ stripslash:
$ if "''f$extract(0,1,p1)'" .nes. "/" then goto nostartslash
$ p1 := "''f$extract(1,"''f$length(p1)'"-1,p1)'"
$ goto stripslash
$ nostartslash:
$ if "''f$length(p1)'" .eq. 0 then goto done
$ if "''f$extract(0,2,p1)'" .eqs. ".." then goto l11
$ slashloc := "''f$locate("/",p1)'"
$ dlen := "''f$length(p1)'"
$ if slashloc .ne. dlen then -
$ goto l1002
$!else
$ thisdir := 'p1'
$ p1 := "''f$extract(slashloc+1,dlen-(slashloc+1),p1)'"
$ goto chdir
$ l1002:
$ thisdir := "''f$extract(0,slashloc,p1)'"
$ p1 := "''f$extract(slashloc+1,dlen-(slashloc+1),p1)'"
$ goto chdir
$ l11:
$ set def [-]
$ p1 := "''f$extract(2,"''f$length(p1)'"-2,p1)'"
$ goto dorest
$ chdir:
$ if "''f$extract(0,1,thisdir)'" .eqs. "[" then -
$ goto l21
$ if "''f$extract(0,1,thisdir)'" .nes. "." then -
$ thisdir := .'thisdir'
$ thisdir := ['thisdir'
$ l21:
$ c = 'f$length(thisdir)' - 1
$ if "''f$extract(c,1,thisdir)'" .nes. "]" then -
$ thisdir := 'thisdir']
$ set def 'thisdir'
$ goto dorest
!
! Comments at end should not slow us down...
!
! Pathnames starting with user$ or sys$ are not munged with.
! Standard unix paths with / and .. in any order and combination
! work fine, going reletive to the current directory. The only
! way to get to the "root" is if the path starts with [xxxxx]
! So "cd [clark]" works, as does "cd [clark]/bin/src" Execution
! can be sped up as you learn to use dots instead of slashes:
! cd clark.bin.src or cd ../bin.src.sccs instead of cd ../bin/src/sccs
!
! Notes on organization: doit: and done: were put where they are
! with the hope that since it has already seen done: it will know
! where it is and get there faster.
!
! The code below could be put just before the exit at done:
! to make it remember where it is all the time, not just when
! you use bye. Actually, bye was created to make this code
! unnecessary and so cd faster. bye records the current
! directory in sys$login:.wd and login.com reads .wd and cds to
! there.
!
! $ rm sys$login:.wd;*
! $ open/write workingdir sys$login:.wd
! $ write workingdir "''p1'"
! $ close workingdir
!
! Author: Ray Clark
! Xerox Webster, N.Y.
! Clark.wbst@PARC-MAXC
!
! Please send me any improvements or bug fixes !
daemon@ucbvax.UUCP (09/15/83)
>From GEOFF5@SRI-CSL Thu Sep 15 09:05:00 1983
First, I no longer have the original letters on the subject, and my list of
DLs in out of date, so if this is not a good or the best address, someone tell
me !
Below is my cd.com . It does not try to deal with device names, and is
simply a hack to act like unix 99.9% of the times I type cd, which it
does since I rattle around on the same disk... I suppose an obvious addition
would be to recognize / as root so that you can say cd /clark/bin instead of
the kludgy cd [clark] and cd bin or cd [clark]/bin, but it has not bothered
me sufficiently yet.
$ if p1 .nes. "" then goto l1
$ p1 := sys$login
$ doit:
$ set def 'p1'
$ done:
$ exit
$ l1:
$ if "''f$extract(0,4,p1)'" .eqs. "SYS$" then goto doit
$ if "''f$extract(0,5,p1)'" .eqs. "USER$" then goto doit
$
$ ! From here it could be an arbitrary path...
$
$ dorest:
$ stripslash:
$ if "''f$extract(0,1,p1)'" .nes. "/" then goto nostartslash
$ p1 := "''f$extract(1,"''f$length(p1)'"-1,p1)'"
$ goto stripslash
$ nostartslash:
$ if "''f$length(p1)'" .eq. 0 then goto done
$ if "''f$extract(0,2,p1)'" .eqs. ".." then goto l11
$ slashloc := "''f$locate("/",p1)'"
$ dlen := "''f$length(p1)'"
$ if slashloc .ne. dlen then -
$ goto l1002
$!else
$ thisdir := 'p1'
$ p1 := "''f$extract(slashloc+1,dlen-(slashloc+1),p1)'"
$ goto chdir
$ l1002:
$ thisdir := "''f$extract(0,slashloc,p1)'"
$ p1 := "''f$extract(slashloc+1,dlen-(slashloc+1),p1)'"
$ goto chdir
$ l11:
$ set def [-]
$ p1 := "''f$extract(2,"''f$length(p1)'"-2,p1)'"
$ goto dorest
$ chdir:
$ if "''f$extract(0,1,thisdir)'" .eqs. "[" then -
$ goto l21
$ if "''f$extract(0,1,thisdir)'" .nes. "." then -
$ thisdir := .'thisdir'
$ thisdir := ['thisdir'
$ l21:
$ c = 'f$length(thisdir)' - 1
$ if "''f$extract(c,1,thisdir)'" .nes. "]" then -
$ thisdir := 'thisdir']
$ set def 'thisdir'
$ goto dorest
!
! Comments at end should not slow us down...
!
! Pathnames starting with user$ or sys$ are not munged with.
! Standard unix paths with / and .. in any order and combination
! work fine, going reletive to the current directory. The only
! way to get to the "root" is if the path starts with [xxxxx]
! So "cd [clark]" works, as does "cd [clark]/bin/src" Execution
! can be sped up as you learn to use dots instead of slashes:
! cd clark.bin.src or cd ../bin.src.sccs instead of cd ../bin/src/sccs
!
! Notes on organization: doit: and done: were put where they are
! with the hope that since it has already seen done: it will know
! where it is and get there faster.
!
! The code below could be put just before the exit at done:
! to make it remember where it is all the time, not just when
! you use bye. Actually, bye was created to make this code
! unnecessary and so cd faster. bye records the current
! directory in sys$login:.wd and login.com reads .wd and cds to
! there.
!
! $ rm sys$login:.wd;*
! $ open/write workingdir sys$login:.wd
! $ write workingdir "''p1'"
! $ close workingdir
!
! Author: Ray Clark
! Xerox Webster, N.Y.
! Clark.wbst@PARC-MAXC
!
! Please send me any improvements or bug fixes !