Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Running 'type' causes false positive hashed command completion
- X-seq: zsh-workers 39099
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Running 'type' causes false positive hashed command completion
- Date: Wed, 24 Aug 2016 20:58:49 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=SHi gxdaN5eG50Kd6Th+CfJPTA9s=; b=ydinLnaUrAsfr5PY1L2A6I6ln//2scgemnK cgF0pTBsHuGcrjg2CVILL+ozQE8yrJKFklY/fIH/B9IqXeJvZqAvULMsO77mJhJx VJKdBPjtlz/Q44WXeGJeoPbw6fJf2oLplSScnwbtYdrGM5mSOFI4JbPNCueo0QCQ zrMBWFbA=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=SH igxdaN5eG50Kd6Th+CfJPTA9s=; b=sk3MoGHzvEd6RLd59VhBWkj/UANGFKJHdq jlv6gmBlIWekg23K84joQk925ZsfeJpN1aybSv/GFD91bdJwr17EuJFE+/yziiy0 /1gt+W+C758GOTPkYdUsIsqVpHb5ZT/15w/VmHZgHYDx91vHEteFaqcyTLZOBm5R z2ki1PRdU=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
$ zsh -f
% cd $(mtemp -d)
% touch sudofoo; chmod +x $_
% ./sudo<TAB>
<becomes>
% ./sudofoo <^C>
% type -w ./sudo
./sudo: none
% ./sudo<TAB>
./sudo sudofoo*
That's wrong because ./sudo does not exist. However, it's hashed:
% print $commands[./sudo]
/usr/bin/./sudo
To confuse matters further, even though "./sudo" is hashed, a subsequent
'type -w ./sudo' will print "none", because the hash node lacks the
HASHED bit in its .flags and the PATH_DIRS option is unset by default.
Backtrace:
(gdb)
890 cmdnamtab->addnode(cmdnamtab, ztrdup(arg0), cn);
(gdb) p arg0
$5 = 0x7ffff7ff2590 "./sudo"
(gdb) bt
#0 hashcmd (arg0=0x7ffff7ff2590 "./sudo", pp=0x7a3f98) at exec.c:890
#1 0x0000000000421507 in findcmd (arg0=0x7ffff7ff2590 "./sudo", docopy=1) at exec.c:776
#2 0x000000000041382c in bin_whence (nam=0x7ffff7ff2580 "type", argv=0x7ffff7ff25a0, ops=0x7fffffffda50, func=0) at builtin.c:3642
#3 0x0000000000407702 in execbuiltin (args=0x7ffff7ff2520, assigns=0x0, bn=0x76ed00 <builtins+4032>) at builtin.c:484
#4 0x000000000042a0e9 in execcmd (state=0x7fffffffe490, input=0, output=0, how=18, last1=1) at exec.c:3660
#5 0x00000000004246be in execpline2 (state=0x7fffffffe490, pcode=131, how=18, input=0, output=0, last1=1) at exec.c:1758
#6 0x000000000042360d in execpline (state=0x7fffffffe490, slcode=5122, how=18, last1=1) at exec.c:1536
#7 0x0000000000422a43 in execlist (state=0x7fffffffe490, dont_change_job=0, exiting=1) at exec.c:1294
#8 0x0000000000422297 in execode (p=0x7ffff7ff24b0, dont_change_job=0, exiting=1, context=0x53acd2 "cmdarg") at exec.c:1085
#9 0x000000000042216f in execstring (s=0x7fffffffe9c5 "type -w ./sudo", dont_change_job=0, exiting=1, context=0x53acd2 "cmdarg") at exec.c:1051
#10 0x00000000004460b9 in init_misc (cmd=0x7fffffffe9c5 "type -w ./sudo", zsh_name=0x7fffffffe9be "zsh") at init.c:1289
#11 0x00000000004478fb in zsh_main (argc=3, argv=0x7fffffffe688) at init.c:1673
#12 0x0000000000406a96 in main (argc=3, argv=0x7fffffffe688) at ./main.c:93
Originally reported as https://github.com/zsh-users/zsh-syntax-highlighting/issues/354.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author