From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8785 invoked by alias); 1 Apr 2018 01:18:57 -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: List-Unsubscribe: X-Seq: 23297 Received: (qmail 6060 invoked by uid 1010); 1 Apr 2018 01:18:57 -0000 X-Qmail-Scanner-Diagnostics: from mail-lf0-f45.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.215.45):SA:0(-1.9/5.0):. Processed in 15.389126 secs); 01 Apr 2018 01:18:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_DKIM_INVALID,T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Quui5Qdi+/9r0nKdfVohXlcoPsGk0rOJmY2D1UBLCuI=; b=RqiCLEtqVtOTk6aWBPCMJKxC5aG06SbzbH87dN4zF3M6uy2t+3PcprsPvf0wd/ltT8 EseHZ+hY2JLqhPHsjNLoS4uCrtKLEDWFGsgKHHPro2RFisQBCqChammNvVEoUzYPATtH TJMocFHsy2BoCeFeisilHt6ZKz+kP1YVLP1hImxt6ZwT8a6UJz+kxYnKQpjSKqpAP3HY Zj2uUFxz5eFOepMXVw8dtCPO3mXKkUQG6jb8Pd8zQsT0BMatIzb4fiBFT54KBdHlENdv E3RAlhPHHoykmzU+y/sO32pOqIyI+KJEz5lWP+kv8n0Zg1LM1K7LeB+oRpsFfokP0AqI SNGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Quui5Qdi+/9r0nKdfVohXlcoPsGk0rOJmY2D1UBLCuI=; b=P/Cnmq5txQ47R54Hf6gkeR7+aFF7roItnrK/xWB9sFnAWdfI1A+fdIyFipdvkwoTEN 1/RT77MhvV2nlRD418SEbjuy29BTKNr7Moic3Sv7VVRql4NJ/pEnj9Bfantlm8wL+fL9 hJnKdfy+i5ZJVDND+0/Rzj002xC/iIDHFJ9U4q4Bh+KeUYCsNbNpMfJldrWHSFKxbhXY ZgyT4bxFlZKQQQUVN7lMPY2ImNXdwyv6K5SKDXwdaljrLdefkPLBCICmDQkRoa7dOTf6 V8z0oXpizC9QX8Qi1AhtpejHGzBH7T+IVdAriN3fCFYTnFnY7YxDM6OGPsTb5c7MjyJw vrqw== X-Gm-Message-State: AElRT7HPd7+YJfMmT4/X/8bKZ7Vk4U4ZARf1kg0h5YpBeO2wUh1n4gDo v3TG8Z7n1dfLS//BGNXcRU3AVhsiGKieP1qDSqb/Uw== X-Google-Smtp-Source: AIpwx4+bddyfBmH2LtgknRIgtB3FPIcOa5k3Vy6LpU2uh5cbr3oHShPjuWtr2JtbkRUVunrRtiHDwmY7cghsXT1KhCo= X-Received: by 10.46.135.82 with SMTP id q18mr2540373ljj.121.1522545517562; Sat, 31 Mar 2018 18:18:37 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <6935145d-785f-f2dd-d4f2-e7ea627e2bc3@eastlink.ca> References: <6935145d-785f-f2dd-d4f2-e7ea627e2bc3@eastlink.ca> From: Bart Schaefer Date: Sat, 31 Mar 2018 18:18:36 -0700 Message-ID: Subject: Re: whence (was Re: local unfunction) To: Ray Andrews Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" On Sat, Mar 31, 2018 at 10:21 AM, Ray Andrews wrote: > > $ whence -wm "zsh*" > zsh: command > zsh5.3: command # binary > zsh5.3:: command # text file What's with the extra ":" there? Is there actually a colon in the file name? > ... I've yet to understand what the point of the '-w' switch is. % zsh() { print nope } % alias zsh='print not this either' % whence -w zsh zsh: alias % whence -wa zsh zsh: alias zsh: function zsh: command % > -a # keep looking after the first match (the one to be executed) is found So far so good. > -m # find all matches of a pattern, subsumes '-a' (executable ONLY unless > ... ) No, this does not subsume -a, because it will only return hits from the internal hash tables. Thus if you have a file named "zsh" in 3 different directories in $path, the command hash table will contain only the first of those, and whence -m will find only that one. However, if you have three differently-named files matching "zsh*" in $path, they will all have separate entries in the command hash table, and whence -m will list all three. > -t # Show non executable (text?) files as well, obviates -a, subsumes 'm'. This being a proposed new flag. I think this points to the source of the confusion. The command hash table will contain the first occurrence of every file name from every directory in $path, even if that first occurrence is not executable, and "whence -m" will show you all of the matching entries in the hash table. The existing -m option subsumes your -t. The other confusion is that -m never searches $path. It always populates the command hash table if necessary and then searches the hash table. % path=(./Src $path) % whence zsh ./Src/zsh % whence -a zsh ./Src/zsh /bin/zsh % whence -m zsh /bin/zsh % There's one magic side-effect of combining -a and -m, which is that -m will find something in the hash table and then -a will search $path for what was found. That's a result of re-using the code that walks the path to do the output formatting for the names found by -m.