Article View: comp.unix.shell
Article #1611Re: Csh question: Doing cd .. from a symbolically linked directory
From: Maarten Litmaath
Date: Wed, 24 Oct 1990 23:39
Date: Wed, 24 Oct 1990 23:39
61 lines
1647 bytes
1647 bytes
In article <JERRY.90Oct24110101@sky.slhisc.uucp>, 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
Technical Details
Message-ID:
<8043@star.cs.vu.nl>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!maartReferences:
<JERRY.90Oct24110101@sky.slhisc.uucp>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <JERRY.90Oct24110101@sky.slhisc.uucp> 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