🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
1 messages
1 total messages Started by Bob Peirce #305 Thu, 01 Nov 1990 13:39
Re: Csh question: Doing cd .. from a symbolically linked directory
#1690
Author: Bob Peirce #305
Date: Thu, 01 Nov 1990 13:39
37 lines
2235 bytes
My brain damaged csh lacks eval and it doesn't set cwd.  It also runs on
an Altos with worknet -- top level directories may be / or @node. 
However, we do have symbolic links, so here is my solution.  I have been
hacking on this for about the last day or two.  It now handles 99% of
anything we might want to do here.  I would dearly love to know how I
can improve it. 

#  Handle typical .. moves from a symbolically linked directory
#  You can go home, rel, abs, .. or ../something.  That's it.
#  On an Altos with worknet, / may also be @node
#  Some aliases may add extraneous /s so we have to squeeze them
#  Logic is to check if you are going home.  If not, check the first
#  char of the arg to see if it is dot, /,  or  @.
#  If we lead off with a dot and the arg is the same as the tail of
#  the arg we are just doing ..  Otherwise we are doing ../something.
#  If we .. all the way to /, we have to set /.
#  If we lead off with  / or @ it is absolute.
#  If we do not lead off with dot, / or @ it is relative so
#  we append the arg to $cwd/.
set cwd = `pwd`
alias	cd	'\\
	set nwd;\\
	set tmp;\\
	set tgt = \!*;\\
	if (x\!* == "x") set nwd = $home;\\
	if (x$nwd != x$home) set tmp = `echo \!* | cut -c1`;\\
	if ("x\$tmp" == 'x\\\\.' && $tgt == $tgt:t) set nwd = $cwd:h;\\
	if ("x\$tmp" == 'x\\\\.' && $tgt != $tgt:t) set nwd = $cwd:h/$tgt:t;\\
	if ("x\$tmp" == 'x\\\\.' && $nwd == "") set nwd = /;\\
	if (x$nwd != x$home && x$tmp == 'x/' || x$tmp == 'x@') set nwd = \!*;\\
	if (x$nwd == "x" && \!* != '..') set nwd = $cwd/\!*;\\
	chdir $nwd;\\
	set cwd = `echo $nwd | tr -s '/'`'

-- 
Bob Peirce, Pittsburgh, PA				  412-471-5320
...!uunet!pitt!investor!rbp			rbp@investor.pgh.pa.us
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads