From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15008 invoked by alias); 3 Jan 2015 05:53:11 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19677 Received: (qmail 6705 invoked from network); 3 Jan 2015 05:53:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Authority-Analysis: v=2.1 cv=T/C1EZ6Q c=1 sm=1 tr=0 a=HOv8TPlFSS3eFj132gCofQ==:117 a=HOv8TPlFSS3eFj132gCofQ==:17 a=Hpgzp-inWqAA:10 a=N659UExz7-8A:10 a=ILrk3uvjQpC_EwriuCUA:9 a=pILNOxqGKmIA:10 Message-id: <54A783C3.3000006@eastlink.ca> Date: Fri, 02 Jan 2015 21:53:07 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: symlink chain. References: <549E3A7B.9010209@eastlink.ca> <20150102170307.7d2e644a@ntlworld.com> <54A6E6B1.6070201@eastlink.ca> <20150102212422.3a761af5@ntlworld.com> <54A7136C.1060102@eastlink.ca> <20150102222140.1303a633@ntlworld.com> <54A72CEF.9090102@eastlink.ca> <54A740F3.4040902@eastlink.ca> <150102210337.ZM22099@torch.brasslantern.com> In-reply-to: <150102210337.ZM22099@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit On 01/02/2015 09:03 PM, Bart Schaefer wrote: > On Jan 2, 5:08pm, Ray Andrews wrote: > } Subject: Re: symlink chain. > } > } Needless to say, I have no idea if this is sound, however: > } > } /* With -m option -- treat arguments as a glob patterns */ > } // if (OPT_ISSET(ops,'m')) { > } if (OPT_ISSET(ops,'m') && **argv != '/' ) { > } > } ... seems to work. > > I wouldn't use the word "work" exactly. All that does is turn off the > pattern matching entirely. You're probably next going to complain that > > % whence -m /\*/bin/zsh I repeat that I have no idea if that is sound, I'm just fooling with it. But I haven't broken it here (yet). $ whence -mas "/usr/bin/zsh" zsh-5.0.7-165-g2194da1 /usr/bin/zsh -> /usr/local/bin/zsh-5.0.7-165-g2194da1 $ whence -mas "*zsh*" zsh-5.0.7-165-g2194da1 /usr/local/bin/zsh -> /usr/local/bin/zsh-5.0.7-165-g2194da1 /usr/bin/zsh -> /usr/local/bin/zsh-5.0.7-165-g2194da1 /bin/zsh -> /usr/local/bin/zsh-5.0.7-165-g2194da1 /usr/local/bin/zsh,3,bart-fix-TRAPDEBUG /usr/local/bin/zsh-2014-11-14 /usr/local/bin/zsh-5.0.7-109-g2598010 /usr/local/bin/zsh-5.0.7-112-g49d6aac /usr/local/bin/zsh-5.0.7-125-g167a15a /usr/local/bin/zsh-5.0.7-136-g0a07ffd /usr/local/bin/zsh-5.0.7-138-g247f754 /usr/local/bin/zsh-5.0.7-159-g89c692e /usr/local/bin/zsh-5.0.7-161-g1cd8023 /usr/local/bin/zsh-5.0.7-165-g2194da1 /usr/local/bin/zsh-5.0.7-dev-0 /usr/local/bin/zsh-RayStyle1 /usr/local/bin/zsh.old /bin/zsh4 /bin/zsh5 ... so pattern matching is still working, so far. > > should return /usr/bin/zsh and /usr/local/bin/zsh, or somthing of the > kind. This is just abusing the purpose of "whence", which is intended > to tell you what a path search would find for a simple command name. Well, what it 'should' be used for is subjective, and of course my views on that are very junior. I want it to give me every command that matches the pattern, and not to crap out if -m is given, just because a full path is specified. Ditto with -a. And I'd like being able to use it to see symlink chains. I think all of that makes the command more intuitive and far more useful even if it is a breach of tradition. > > If we *really* want this behavior -- which I submit that we don't, as > we're wandering into silly territory like whence -m '*bin*' returning > all commands in all directories named "bin", Speaking for myself, that's not something I'd begin to want. I want it to do what it advertises itself to do, but with no gotchas. I'd not call that silly. > so we should stop futzing > around with "whence" -- then the correct thing is rewriting the hash > table scan to look at both the keys and the values when doing the > pattern matching. > > Which has ramifications beyond "whence" because it uses the same hash > table scan routines as everything else. I confess I'm actually a bit > surprised that PWS was willing to hack up something as deeply involved > in the internals as xsymlinks() [in which we just finished fixing other > obscure bugs] in order to implement whence -S. Of course we leave final decisions to you guys as to what can be done safely. But once I lean how to preserve them, I'll be keeping both of those: ... && **argv != '/' ... changes, cuz they sure look good to me. (And the symlink chain once I learn how to import a patch.) That's presuming a better method isn't forthcoming. > Shell functions exist so that if something like whence doesn't do what > you want, you can write something else that does. Yup. I had those link-chains displayed with 'namei' just fine, but I still think it is a natural addition to whence. You guys know best.