Path: utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.shell Subject: Re: Csh question: Doing cd .. from a symbolically linked directory Message-ID: <8043@star.cs.vu.nl> Date: 24 Oct 90 23:39:16 GMT References: Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Distribution: comp.unix.shell Organization: VU Dept. of Computer Science, Amsterdam, The Netherlands Lines: 61 In article , jerry@slhisc.uucp (Jerry Liebelson) writes: )... ) SITUATION: ) ) 1. cd /tmp ) 2. mkdir -p a/b ) 3. ln -s a/b c ) ) PROBLEM: ) ) 1. cd /tmp/c ) 2. pwd (output is "/tmp/c") ) 3. cd .. ) 4. pwd (output is "/tmp/a", not "/tmp" ! ) ) ) QUESTION: ) Is there a way to set things in the csh such that when I do the cd .. ) from /tmp/c, I will end up in /tmp and not in /tmp/a? Yes: alias cd 'cd `xcd $cwd \!*`' ...where `xcd' is the following shell script, located somewhere in your PATH. (You may have to change the `cd' in the alias to `chdir'.) --------------------cut here-------------------- #!/bin/sh # # alias cd 'cd `xcd $cwd \!*`' case $# in 1) echo $HOME exit 0 ;; 2) case $2 in /*) echo "$2" exit 0 ;; *..*) ;; *) echo "$1/$2" exit 0 esac esac # /a/b/c/symlink1/symlink2/../../src -> /a/b/c/src SED=' : loop s|/[^/]*/\.\.||g t loop ' echo "$1/$2" | sed "$SED" --------------------cut here-------------------- -- Waiting for this to work: cat /internet/cs.vu.nl/finger/maart