zsh-workers
 help / color / mirror / code / Atom feed
* Re:  bug 3.1.5 symlinks & cd
@ 1998-11-16  9:28 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1998-11-16  9:28 UTC (permalink / raw)
  To: zsh-workers


Phil Pennock wrote:

> 
> Using a stock zsh-3.1.5, there seems to be some problem with completion
> using one interpretation of a directory tree with symlinks, and cd using
> another.  (Linux 2.0.x on x86.)
> 
> % zsh-3.1.5 -f
> machinename% PS1='%~%# '
> ~% mkdir tmp/tst && cd tmp/tst
> ~/tmp/tst% mkdir foo foo/bar wibble
> ~/tmp/tst% ln -s foo/bar .
> ~/tmp/tst% cd bar
> ~/tmp/tst/bar% 
> 
> At this points, try tab-completing "cd ../" and you get "../bar", try
> ../w<tab> and it beeps.  Try "../../w<tab>" and you get the wibble
> directory completed, but:
> 
> ~/tmp/tst/bar% cd ../../wibble
> cd: no such file or directory: ../../wibble
> ~/tmp/tst/bar% cd ../wibble
> ~/tmp/tst/wibble% compctl -L cd
> compctl: no compctl defined for cd
> 
> Note that the ../wibble refuses to tab-complete.

Damn. Currently I see no simple solution for this. It looks as if we
would need a compctl flag for completing paths with special sym-link
handling just for `cd' and friends which seem to be the only builtins
that use CHASESYMLINKS for their arguments.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: bug 3.1.5 symlinks & cd
@ 1998-11-18 13:41 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1998-11-18 13:41 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Sven Wischnowsky wrote:
> > So the question is: do you think that this is enough (probably with
> > some more work on the function) or should we build this into the shell?
> 
> Isn't the problem only with ../ ?  -/ and the rest happily follow
> symlinks, it's only when going up there's a problem.  In that case, it
> would be OK to use -/ most of the time and only have a special
> function when there's a ../ in the string so far.  As the only case
> where you would normally use this is ../ at the start (although I've
> been known to use $PWD/.. when I needed an absolut path), I should
> have thought a shell function for this one case would have been quite
> good enough.  ../../ etc. is a complication, but one a function could
> still easily handle. (Unless I've missed some other potential
> problem.)

I don't see any other problem either. So I won't dive into the
completion code today, fine.


Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: bug 3.1.5 symlinks & cd
@ 1998-11-18  9:09 Sven Wischnowsky
  1998-11-18 13:06 ` Peter Stephenson
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1998-11-18  9:09 UTC (permalink / raw)
  To: zsh-workers


Phil Pennock wrote:

> 
> Typing away merrily, Bart Schaefer produced the immortal words:
> > On Nov 13,  9:19pm, Phil Pennock wrote:
> > } Using a stock zsh-3.1.5, there seems to be some problem with completion
> > } using one interpretation of a directory tree with symlinks, and cd using
> > } another.
> > 
> > This isn't new.  It behaves the same way in 3.0.5.  `setopt chaselinks'
> > will make the effect go away.
> 
> Yes, but:
>        CHASE_LINKS (-w)
>               Resolve symbolic links to their  true  values  when
>               changing directory.
> 
> The 'effect' only goes away insofar as this avoids the problem by never
> having a symbolic-link as part of PWD.
> 
> If you want to have the 'real' view of a layout, fine.  But forcing this
> option just to get a consistent interpretation of the FS dodges the fact
> that two different parts of the shell are taking differing approaches to
> symbolic-links pointing to directories.  Completion ignores the symbolic
> aspect of PWD, such that a ../ always uses the underlying 'true' layout,
> whilst cd handles the symbolic links.  This is a conflict that's
> entirely due to two parts of zsh doing things very differently.

I agree that this is a ugliness. But (as I already wrote) the only way 
I see to fix this cleanly is to add yet another option for compctl to
make -f, -g, and -/ use CHASELINKS. On the other hand, this is a bit
of an overkill considering that this would be useful only for cd and
the like.
A (partial) solution is to use a shell function, like this:

  compctl -K cdcomp -S/ -q cd pushd

  cdcomp() {
        local d r
        if [[ "$1" == */* ]]
        then
                d="${1%%/*}"
                r="${1#*/}"
                cd "$d" >& /dev/null
                reply=( ${r}*${2}(N-/) )
                reply=( $d/$reply )
                cd - >& /dev/null
        else
                reply=( ${1}*${2}(N-/) )
        fi
  }

So the question is: do you think that this is enough (probably with
some more work on the function) or should we build this into the shell?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 9+ messages in thread
* bug 3.1.5 symlinks & cd
@ 1998-11-13 21:19 Phil Pennock
  1998-11-14  5:48 ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Phil Pennock @ 1998-11-13 21:19 UTC (permalink / raw)
  To: zsh-workers

Using a stock zsh-3.1.5, there seems to be some problem with completion
using one interpretation of a directory tree with symlinks, and cd using
another.  (Linux 2.0.x on x86.)

% zsh-3.1.5 -f
machinename% PS1='%~%# '
~% mkdir tmp/tst && cd tmp/tst
~/tmp/tst% mkdir foo foo/bar wibble
~/tmp/tst% ln -s foo/bar .
~/tmp/tst% cd bar
~/tmp/tst/bar% 

At this points, try tab-completing "cd ../" and you get "../bar", try
../w<tab> and it beeps.  Try "../../w<tab>" and you get the wibble
directory completed, but:

~/tmp/tst/bar% cd ../../wibble
cd: no such file or directory: ../../wibble
~/tmp/tst/bar% cd ../wibble
~/tmp/tst/wibble% compctl -L cd
compctl: no compctl defined for cd

Note that the ../wibble refuses to tab-complete.

HTH
-- 
--> Phil Pennock ; GAT d- s+:+ a22 C++(++++) UL++++/I+++/S+++/H+ P++@ L+++
E-@ W(+) N>++ o !K w--- O>+ M V !PS PE Y+ PGP+ t-- 5++ X+ R !tv b++>+++ DI+ D+
G+ e+ h* r y?


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1998-11-18 23:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-16  9:28 bug 3.1.5 symlinks & cd Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1998-11-18 13:41 Sven Wischnowsky
1998-11-18  9:09 Sven Wischnowsky
1998-11-18 13:06 ` Peter Stephenson
1998-11-18 19:25 ` Bart Schaefer
1998-11-18 22:41 ` Phil Pennock
1998-11-13 21:19 Phil Pennock
1998-11-14  5:48 ` Bart Schaefer
1998-11-15  3:01   ` Phil Pennock

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).