* 3.1.9 completion problems: automounter
@ 2000-09-11 14:36 E. Jay Berkenbilt
2000-09-11 17:33 ` more wishes with automounter Alexandre Duret-Lutz
2000-09-12 5:20 ` 3.1.9 completion problems: automounter Bart Schaefer
0 siblings, 2 replies; 7+ messages in thread
From: E. Jay Berkenbilt @ 2000-09-11 14:36 UTC (permalink / raw)
To: zsh-users
I have /home set up to use an automounter. Therefore, directories
under /home doesn't exist until I specifically access them. As an
example, we have a directory called /home/sysadmin. If I type
ls /home/sysadmin/
and hit TAB, I get no completions because zsh doesn't appear to
attempt to access /home/sysadmin at this point. It only accesses
/home to see whether sysadmin exists, which it doesn't. I have to do
something explicit to access /home/sysadmin first before I can use
completion.
Under tcsh, ls /home/sysadmin/ TAB works because tcsh actually
accesses /home/sysadmin before deciding whether it exists or not.
I'd like to know whether there is a way to get zsh to try to access
/home/sysadmin before deciding that there are no completions that
start from it. Note: I am NOT looking for a way to type /home/sys TAB
and get sysadmin. I am only looking for a way to get zsh to try
accessing the directory before deciding that it doesn't exist.
--
E. Jay Berkenbilt (ejb@ql.org) | http://www.ql.org/q/
^ permalink raw reply [flat|nested] 7+ messages in thread
* more wishes with automounter
2000-09-11 14:36 3.1.9 completion problems: automounter E. Jay Berkenbilt
@ 2000-09-11 17:33 ` Alexandre Duret-Lutz
2000-09-12 6:58 ` Bart Schaefer
2000-09-12 5:20 ` 3.1.9 completion problems: automounter Bart Schaefer
1 sibling, 1 reply; 7+ messages in thread
From: Alexandre Duret-Lutz @ 2000-09-11 17:33 UTC (permalink / raw)
To: zsh-users
Hi,
I use automounter, too, and have trouble with Zsh.
I have a bunch of automounted NFS directories in
/var/autofs/nfs/
Since the automountable directories are invisible [*] in
/var/autofs/nfs/ until they are mounted, and because
I don't wan't to remember their names, I have setup
a /nfs/ directory with symbolic links to the automounted
directories:
/nfs/hosts1 -> /var/autofs/nfs/host1
/nfs/hosts2 -> /var/autofs/nfs/host2
/nfs/hosts3 -> /var/autofs/nfs/host3
etc...
The problem is that using Zsh to complete /nfs/hos<TAB> will
mount *all* the directories, because the completion code stat()
all links (and stat()ing a link will lead to the mount of the
linked directory). I believe that Zsh may use lstat() instead,
but since I don't know where that guilty stat() is I haven't
tried.
[*] another wish would be that Zsh complete those invisible
directories; or more generaly: give the user the possiblity
to add "virtual files" (anywhere he want), that Zsh would
use for completion.
--
Alexandre Duret-Lutz
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 3.1.9 completion problems: automounter
2000-09-11 14:36 3.1.9 completion problems: automounter E. Jay Berkenbilt
2000-09-11 17:33 ` more wishes with automounter Alexandre Duret-Lutz
@ 2000-09-12 5:20 ` Bart Schaefer
2000-09-12 6:14 ` Bart Schaefer
1 sibling, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2000-09-12 5:20 UTC (permalink / raw)
To: E. Jay Berkenbilt, zsh-users
On Sep 11, 10:36am, E. Jay Berkenbilt wrote:
} Subject: 3.1.9 completion problems: automounter
}
} I'd like to know whether there is a way to get zsh to try to access
} /home/sysadmin before deciding that there are no completions that
} start from it.
Hmm. I've just been playing with zsh on a machine at work that has an
automounted directory, and I can't reproduce the behavior you described.
If I type
zsh% ls /host/hostname<TAB>
I get a feep. But if instead I type
zsh% ls /host/hostname/<TAB>
with the trailing slash, the mount happens and I get completions. This
happens both with and without the new completion system loaded. With
old-style completion, I get the following strace output, starting from
the point at which the TAB I typed is read:
read(10, "\t", 1) = 1
fcntl(0, F_DUPFD, 10) = 11
close(0) = 0
access("/bin/ls", X_OK) = 0
stat("/bin/ls", {st_mode=S_IFREG|0755, st_size=43024, ...}) = 0
open("/misc/moonbase/", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 0
fstat(0, {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0
So zsh *does* try to access the directory before deciding that it does
not exist. Does open("/home/sysadmin/", ...) fail on your system?
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 3.1.9 completion problems: automounter
2000-09-12 5:20 ` 3.1.9 completion problems: automounter Bart Schaefer
@ 2000-09-12 6:14 ` Bart Schaefer
0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2000-09-12 6:14 UTC (permalink / raw)
To: E. Jay Berkenbilt, zsh-users
On Sep 12, 5:20am, Bart Schaefer wrote:
}
} Hmm. I've just been playing with zsh on a machine at work that has an
} automounted directory, and I can't reproduce the behavior you described.
[...]
} with the trailing slash, the mount happens and I get completions. This
} happens both with and without the new completion system loaded.
I'm sorry, I was mistaken about having loaded new completion. With the
new completion system *properly* loaded, I *can* get this to happen.
So here's the answer to your question:
zstyle -e ':completion:*' file-patterns '[[ -d $PREFIX:h/. ]]'
This tests whether the prefix (or "/", if there's no prefix, but that's
harmless) contains a "." directory, then ignores the result; so the only
effect is to force the directory to be automounted. Since it does not
set a value for $reply (see the "zstyle -e" doc), completion proceeds as
if the style were not set at all.
Note that if you actually *want* to set file-patterns for some other
context, you'll have to add the test to those styles as well, or the
side-effect will go away in those contexts.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: more wishes with automounter
2000-09-11 17:33 ` more wishes with automounter Alexandre Duret-Lutz
@ 2000-09-12 6:58 ` Bart Schaefer
2000-09-13 9:32 ` Alexandre Duret-Lutz
0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2000-09-12 6:58 UTC (permalink / raw)
To: Alexandre Duret-Lutz, zsh-users
On Sep 11, 7:33pm, Alexandre Duret-Lutz wrote:
} Subject: more wishes with automounter
}
} /nfs/hosts1 -> /var/autofs/nfs/host1
} /nfs/hosts2 -> /var/autofs/nfs/host2
} /nfs/hosts3 -> /var/autofs/nfs/host3
} etc...
}
} The problem is that using Zsh to complete /nfs/hos<TAB> will
} mount *all* the directories, because the completion code stat()
} all links (and stat()ing a link will lead to the mount of the
} linked directory). I believe that Zsh may use lstat() instead,
} but since I don't know where that guilty stat() is I haven't
} tried.
I think the stat must be an effect of the way _path_files does globbing
to try to segregate files by type. I don't see any stat() calls in
strace output if I don't have any styles set (and this time I did check
that the new completion system really was loaded (blush)).
Try this:
ztyle -e ':completion:*' file-patterns \
'[[ $PREFIX == /nfs/[^/]# ]] && \
{ setopt noglob ; reply=(*(@)) ; setopt glob }'
(Twaddling noglob like that was the only way I could get zstyle -e to put
a file pattern into $reply -- the eval-ing messed up any other quoting I
could think of.) This just says that if you're completing within the
/nfs/ directory itself, don't consider anything other than symlinks. As
I'm not sure why/where those links are getting stat()d, this may not be
of any help ... but then again, it may.
} [*] another wish would be that Zsh complete those invisible
} directories; or more generaly: give the user the possiblity
} to add "virtual files" (anywhere he want), that Zsh would
} use for completion.
The article that PWS referenced about this is zsh-users/3408.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: more wishes with automounter
2000-09-12 6:58 ` Bart Schaefer
@ 2000-09-13 9:32 ` Alexandre Duret-Lutz
2000-09-13 15:02 ` Bart Schaefer
0 siblings, 1 reply; 7+ messages in thread
From: Alexandre Duret-Lutz @ 2000-09-13 9:32 UTC (permalink / raw)
To: zsh-users
>>> "Bart" == Bart Schaefer <schaefer@candle.brasslantern.com> writes:
[...]
Bart> Try this:
Bart> ztyle -e ':completion:*' file-patterns \
Bart> '[[ $PREFIX == /nfs/[^/]# ]] && \
Bart> { setopt noglob ; reply=(*(@)) ; setopt glob }'
Bart> (Twaddling noglob like that was the only way I could get
Bart> zstyle -e to put a file pattern into $reply -- the
Bart> eval-ing messed up any other quoting I could think of.)
Bart> This just says that if you're completing within the /nfs/
Bart> directory itself, don't consider anything other than
Bart> symlinks. As I'm not sure why/where those links are
Bart> getting stat()d, this may not be of any help ... but then
Bart> again, it may.
This worked (i.e. directories are not automounted as a side effect
of completion). But I couldn't get it to complete symlinks and
directories (my /nfs/ directory contains both). Using:
zstyle -e ':completion:*' file-patterns \
'[[ $PREFIX == /nfs/[^/]# ]] && \
{ setopt noglob ; reply=(*(@,/)) ; setopt glob }'
Leads to:
~ % ls /nfs/<TAB>
_path_files:327: bad pattern: /nfs/*(@
Bart> } [*] another wish would be that Zsh complete those invisible
Bart> } directories; or more generaly: give the user the possiblity
Bart> } to add "virtual files" (anywhere he want), that Zsh would
Bart> } use for completion.
Bart> The article that PWS referenced about this is zsh-users/3408.
Thanks, I had to get it from the archives
(Murphy's law: my zsh-users mbox bumps from 3406 to 3408...)
--
Alexandre Duret-Lutz
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: more wishes with automounter
2000-09-13 9:32 ` Alexandre Duret-Lutz
@ 2000-09-13 15:02 ` Bart Schaefer
0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2000-09-13 15:02 UTC (permalink / raw)
To: Alexandre Duret-Lutz, zsh-users
On Sep 13, 11:32am, Alexandre Duret-Lutz wrote:
} Subject: Re: more wishes with automounter
}
} zstyle -e ':completion:*' file-patterns \
} '[[ $PREFIX == /nfs/[^/]# ]] && \
} { setopt noglob ; reply=(*(@,/)) ; setopt glob }'
}
} Leads to:
}
} ~ % ls /nfs/<TAB>
} _path_files:327: bad pattern: /nfs/*(@
This is because _files splits the file-patterns at commas on line 58. I'm
not sure why, or how to fix it. It might be to replace
pat="${${${sdef%%:${tag}*}//\\:/:}//,/ }"
with
pat="${${${sdef%%:${tag//,/ }*}//\\:/:}}"
but I fear that only Sven knows for sure. In any case, a qualifier with
a comma in it would interact badly with the file-sort tag, because it will
be rewritten as e.g. *(@,/Om), which is not what you meant.
The workaround is to use reply=(*(@) *(/)) in your style instead.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2000-09-13 15:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-11 14:36 3.1.9 completion problems: automounter E. Jay Berkenbilt
2000-09-11 17:33 ` more wishes with automounter Alexandre Duret-Lutz
2000-09-12 6:58 ` Bart Schaefer
2000-09-13 9:32 ` Alexandre Duret-Lutz
2000-09-13 15:02 ` Bart Schaefer
2000-09-12 5:20 ` 3.1.9 completion problems: automounter Bart Schaefer
2000-09-12 6:14 ` Bart Schaefer
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).