From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22868 invoked from network); 21 Nov 2022 01:46:08 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Nov 2022 01:46:08 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1668995168; b=qRQKjJvrZKYwfzlUv3lRnCPqMCrVY8Qy9gGJsqJoA1Pu9bGCP5+6Xd8Wu5tFGwcljgxh/oO4jI tNEVhL0ev+BJP3FwXzlq+vCtsyjb/OYoaLCOkFtMU56AhsGR2q3q/B3pF0IkVmh8C7xHTWBDpa 0oioMVsTVvABhOuwsUQVft2L4Y3uRrupUHS4CKqr6kJYi2DShZzYhelZzZRuJv4THAPh7bzQXI pipcXnwKsErhXb0tubPZNeDK98xOYYrzJ19bCStMvP6fx2Z5FR9OTfOdMyypOzNkqLLQIybXMs 4FODs+Chew9sqggGX16fu5RahpGhGeZ6QWLu0RQxBEMWSA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oa1-f44.google.com) smtp.remote-ip=209.85.160.44; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1668995168; bh=pFrZIe2VxNes5OeQwGxlv3oxJuiDdQV5TJ4tGyepESk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature:DKIM-Signature; b=fQ6oqFWg9h4S4cO3O9nUkbJFBQs2jruyw4h8EB29w8WY8+vkoHimqodJrtNEpbZRhrf2NLORwD bWUTntAEh6594Y7I01Nzw7VGfS1usNhQ++OQrHEQoMXiT4JoJbeGppDEYZW1dY5yewrmA2LZNA Qa4ej6pt8oHi0GzE2icYxkR7klVb5fGFFzp3RsE6SrWy5uV+OBvWEKY/BQlB9zBZlgPqyfTSFb pklC9iruFJIAN/QR6Etnh+E6jucU17WYvdsGv1QGpKqBxxllaPNOTrYODvQZdc8lE5rr7FwD7z LCIEMnun3aTO89wr87LaBGYjcbF5lyRE7hSzVyGL2I45Sg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=u4yD+HVsOz5XEKc7Ir1ojaHpAgbhTTukn0LAvgo2lBo=; b=gQ98TbePHGEgye56i23mfGtA+B 4AT+VTA3OzvYSbXUE5NNk+R32x3jHyZM5eLB7TaiRnxAYNoqGc/KjWWFROmm+38uiHU0q/idsMCN8 63luEM+6g5INxnMiFUuIKIVTMv0NREQ425hQ3AJrd9oSWoHjqjV0aWRSxWqd0VSPBJdyYCIHRsS6p jq57TWqRImMOsubd/qluxZ4w9sJjMgZYrnAixf0i+uIszR/YAqgmMib9UbMcSCwQjk48Sszc09xa4 olJsMEG6VBw1ptI4A1MVItEPm24iQZEmjFRzRnvSvVxCMM7IPxBB9yFOlxIzycI/wpJootG5+lLyz rafWuLVA==; Received: by zero.zsh.org with local id 1owvst-0000sc-D5; Mon, 21 Nov 2022 01:46:07 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oa1-f44.google.com) smtp.remote-ip=209.85.160.44; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-oa1-f44.google.com ([209.85.160.44]:33651) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1owvsZ-0000WV-ED; Mon, 21 Nov 2022 01:45:47 +0000 Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-13bd2aea61bso12264438fac.0 for ; Sun, 20 Nov 2022 17:45:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=u4yD+HVsOz5XEKc7Ir1ojaHpAgbhTTukn0LAvgo2lBo=; b=BHBFcdQRYIB8b/YuDJ5RGhcySULUobMbAtSEMG9RHhci6nqVlyiv0Nzchx/Uc9zLjW b23ligQAwHUp5S1pptxxRdXurhlsPHKY9d57nGK/Ocbtb9KjTiMa0bk+sO3O3tKZ8tAz HFIv4o5N3zH0vsVshoAGRccJWuuyuq4h3iygvqhjpLcP9+a13/+nlJqo3M4caUSOrL0G CvTcP4BVzpTJgI7o07rPAucRSCP3ZpUwjImj8c/1zGY02OE4dBmQdwMc4AhSQ4R73xOJ lmBucQfO3VtEUf/eKenxOSdrIlYl6m7lDIsz8FP74U6O8z4waAn1iBNNG+ir3es+UvgY X5TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u4yD+HVsOz5XEKc7Ir1ojaHpAgbhTTukn0LAvgo2lBo=; b=Nhg2dadAUwplHcAdC6a1X/JSmGlUMhx1EHadU+2RncZm9MPmPSmedd8wpBJDywebgc nPeNm8tAC+fQOs9Qhg1YYJ2+TGmrX+5oFR+7GLj9wXIZORKrNZC+SYunUU4Q8wDhXsmz LEyM1WSgvu6pPH6f1981C2KXCj/J9GGJSob3u2GmdKUjAULghmQos8BLI83NiCbM8iPO JDJJ/XZRxgLwUMRoS/iqHxIwr1f6P9Dvz3LRH18EemhTrCJHlPhvQssJcaa56+IQYNFp qDPZimTledy47lYzppVTb1taSfuwWARrvdbWqQCjhaxo07fl4uPWBCIfRJsU+az7m+3y ZmzA== X-Gm-Message-State: ANoB5pkloRSM1nh9Jz/FpS4ZazecCQ5o0edPXxg5SL7Q3ivSJRC+BG97 OqiBleLhnkxoG2zToeV/cvvdD/sM9yk= X-Google-Smtp-Source: AA0mqf60igbjJFoerNWPdHtcDMAYz+QIruBhWLHaWQx80YLPRxXWF32Vs3CmgbLIc6XXgPWlplWjGw== X-Received: by 2002:a05:6870:e90:b0:141:d8d1:2b2b with SMTP id mm16-20020a0568700e9000b00141d8d12b2bmr78300oab.254.1668995146270; Sun, 20 Nov 2022 17:45:46 -0800 (PST) Received: from CptOrmolo.darkstar (cpe-76-184-110-212.tx.res.rr.com. [76.184.110.212]) by smtp.gmail.com with ESMTPSA id s7-20020aca4507000000b0035a81480ffcsm3800730oia.38.2022.11.20.17.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 17:45:45 -0800 (PST) Date: Sun, 20 Nov 2022 19:45:42 -0600 From: Matthew Martin To: Stefan Schmidt Cc: zsh-workers@zsh.org Subject: Re: whence not behaving as expected with noaliases set Message-ID: Mail-Followup-To: Stefan Schmidt , zsh-workers@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 51004 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Sun, Oct 23, 2022 at 08:31:58PM +0200, Stefan Schmidt wrote: > Hello! > > The documentation on whence states: > > > For each name, indicate how it would be interpreted if used as a command name. > https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html > > This works as expected if an alias is defined but if the `noaliases` option is set `whence` still returns the alias (same for `type`, `where` and `which`). > Am I misinterpreting or misunderstanding something here or is there in fact a contradiction between the documentation and the implementation? I think your interpretation is correct. This seems straight forward enough to fix. Diff is mostly indentation changes. diff --git a/Src/builtin.c b/Src/builtin.c index a7b7755a7..2298b1559 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3902,9 +3902,11 @@ bin_whence(char *nam, char **argv, Options ops, int func) * We're not using it, so search for ... */ /* aliases ... */ - informed += - scanmatchtable(aliastab, pprog, 1, 0, DISABLED, - aliastab->printnode, printflags); + if (isset(ALIASESOPT)) { + informed += + scanmatchtable(aliastab, pprog, 1, 0, DISABLED, + aliastab->printnode, printflags); + } /* and reserved words ... */ informed += @@ -3944,21 +3946,23 @@ bin_whence(char *nam, char **argv, Options ops, int func) if (!OPT_ISSET(ops,'p') && !allmatched) { char *suf; - /* Look for alias */ - if ((hn = aliastab->getnode(aliastab, *argv))) { - aliastab->printnode(hn, aliasflags); - informed = 1; - if (!all) - continue; - } - /* Look for suffix alias */ - if ((suf = strrchr(*argv, '.')) && suf[1] && - suf > *argv && suf[-1] != Meta && - (hn = sufaliastab->getnode(sufaliastab, suf+1))) { - sufaliastab->printnode(hn, printflags); - informed = 1; - if (!all) - continue; + if (isset(ALIASESOPT)) { + /* Look for alias */ + if ((hn = aliastab->getnode(aliastab, *argv))) { + aliastab->printnode(hn, aliasflags); + informed = 1; + if (!all) + continue; + } + /* Look for suffix alias */ + if ((suf = strrchr(*argv, '.')) && suf[1] && + suf > *argv && suf[-1] != Meta && + (hn = sufaliastab->getnode(sufaliastab, suf+1))) { + sufaliastab->printnode(hn, printflags); + informed = 1; + if (!all) + continue; + } } /* Look for reserved word */ if ((hn = reswdtab->getnode(reswdtab, *argv))) { diff --git a/Test/B13whence.ztst b/Test/B13whence.ztst index 3b35835fe..658a9bcab 100644 --- a/Test/B13whence.ztst +++ b/Test/B13whence.ztst @@ -32,3 +32,13 @@ whence -S flip || whence -S loop || whence -s flip || whence -s loop ) 1:whence deals with symlink loops gracefully + + ( + alias echo=print + whence echo + setopt noaliases + whence echo + ) +0:whence ignore aliases with NO_ALIASES set +>print +>echo