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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22501 invoked from network); 12 Sep 2020 08:35:50 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Sep 2020 08:35:50 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1599899750; b=ul7MdF5dPwJmDgCGPxMS/GO85DxkZAaa4aS02Q5KZBMkdiK2xRb85QlHadQrul0BonslyL1flz T0qdKMZuoBJa81mTndXvIm2p6iR+fgEDamJ5h46dyHeZucBzu5FW0ztEvtv5fYil70ffi2Wvka Q1PqVwe2NlH/ruPi4JGuiilZOS4eKpNElaqi61makZDJQnAk1KCtLYyolN8KlE0r+qWBRbqcd+ eMEIry63rlZQD4EEIYsI2Aei49Gn6VQkv5I5r+0eH3scNXdTMeqhieqUc978yM4TePK890jfgv W0Mgnur8mOPyLNapbSCAywZorRrZd4Dnu7fwJ/7yQvz4Kg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f174.google.com) smtp.remote-ip=209.85.167.174; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1599899750; bh=70037XYh3teXajLCPc2VSG2nJT+PHXqZBGUM5IWMUUk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=GdplrgRamqP/vN6P0ZwjF/NYg+U0zYrePRGgFVmqBHsVTM0qS+SKionc8YXHmYLq6wd+TbQDyG qRVvnBwRIq5+QWcusgKkFgdrNdjmLlGFQhZZMKBzxRtz7SJeJEMFs2tu++gms0UEiAyRShMoN5 7/Zjl2sqQADQbZgnyO1mZd7E+JLTu/gvOO7RRTRanf3+Q4aLH2NZRByGW1Vs0znhCnzXgIm/ym h7pZl4fbunIOETLMsbb5SPFZNlN/tbFomcf1m5f7LKVmVq8IApnCRuqanSTYIPk0dgIpcTV0Ex Tyfthi0djbt4ivFwL7f2kF/by1G6TNSX2H3jZkmBPHLf1Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=oVPZdUHe+qG30PLr/93321F9SShBbY/OPzB+UzDEBgU=; b=XUUSSkBROObX1Gjpb4oA6cOEVS njSUTAzXEK0b+BGE4RpBQam8L06/KwAj7rZxUn4hjOIfH1vMveWPTNm7uAolI0+wcxn0dku746hI2 Z5BLOA4oADsbZD9uQs11dXJqjsMPGDWmui1U6022cifo4TSEQtHV9Q0m6HuQ+AHFOtxbs+ckiYhXD BODsUgKy5lEKbenS/ekGUoA39kf7hjnXXWrHjCn7/sWZF3rLIiQHWMfn6IZy9bVv1iavjgPLARQBF uZvL/8nAZs0w6Wr22lSsJTKlgcEcCQUkcbwoGC2ixkXpLpRIHdQ89E35B1PwN9ID1lRbf4CeYV34s +HIpH8jQ==; Received: from authenticated user by zero.zsh.org with local id 1kH10Z-0005s7-T4; Sat, 12 Sep 2020 08:35:43 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f174.google.com) smtp.remote-ip=209.85.167.174; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oi1-f174.google.com ([209.85.167.174]:45951) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kH10H-0005ic-Mb; Sat, 12 Sep 2020 08:35:29 +0000 Received: by mail-oi1-f174.google.com with SMTP id d189so11933621oig.12 for ; Sat, 12 Sep 2020 01:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oVPZdUHe+qG30PLr/93321F9SShBbY/OPzB+UzDEBgU=; b=WHUfnbLnmBIfJ+rTKJcuWyrOtaRQF0IQC7uVUEVIeoS5yC24xYvXTpfRGXn9saweNZ dtek7FiUyA631GjrCiOJ/iMj+r1GgycnPPRvy0t/cczDobRbtfIOVTxeLmBF63b1sFvN AIktvhsbm3nmWSsaehQYz7BNPACpzYyyIED1RXoTfpTnhplBX4D/QizLxgdXHQJu9QSx 72Vmww+8EJGDtffbdYsOmDZnhhrX6FL6XBW9WDz/z8C96qeYINjUhIQHNuSxmVazH0AU 8vxNqdIYMIV3i82O03YxKTnj68TAz/zFnKzeZASJeHqe5keFDlEAR8La0EQ4aldfZeQP O6Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oVPZdUHe+qG30PLr/93321F9SShBbY/OPzB+UzDEBgU=; b=tkHkezxyj0RGsecNKShgwJtT13tQSP4r7KmT6CMNkVdlUTn0R385heCCy6nOJ6tdP1 rTO02sh2y8vdOvcoFcl78TUVX5v/S+Idd9o7gKvH+1ZPbJK0/RUFWHarghNyMFZtVySK 74adJZ9YDZY+I98OvW6gQXunqXTY2q5eyj+8kvb9ifYLJgmaXqghGWuhGMClR4cexcDb 9YxaT83WA/t6j/VTtvY6suF1pR8R61E824YqoVXZ2SvazCMlyx9DIi/TTxN018UI+g9b eBloot+UnY64vtGAQYhMeM2wansUQkvfseZXw/eJjnOSkC/qlxlus5sB5Xc6Kj9dBB1D nytA== X-Gm-Message-State: AOAM532d1+JukH1+aINbzclZnQlr+6AFezroL4wC1OWubBOdHYnlrbVd dZaTPlxoc3QQnNgOm7k9/ihV8FRYOUp2qKj2u9QQ+A== X-Google-Smtp-Source: ABdhPJy7YBkiomImDpTiTp8Js3sFJdmFaaYI8ZKQ29C30klvnfDWisrlEXnMeiXxlPmkdkIt2BkKW44FhRPhW16sSPw= X-Received: by 2002:aca:3ac6:: with SMTP id h189mr3547986oia.132.1599899723353; Sat, 12 Sep 2020 01:35:23 -0700 (PDT) MIME-Version: 1.0 References: <20200911144852.GA1669764@fullerene.field.pennock-tech.net> <20200911161000.GA1679994@fullerene.field.pennock-tech.net> In-Reply-To: From: Bart Schaefer Date: Sat, 12 Sep 2020 01:35:12 -0700 Message-ID: Subject: Re: Possible bug: HASH_CMDS has no observable effect To: Roman Perepelitsa Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47373 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: Archived-At: On Sat, Sep 12, 2020 at 12:02 AM Roman Perepelitsa wrote: > > Do I understand it correctly that this is working as intended? It > appears to contradict the documentation for HASH_CMDS, which states > that commands are hashed when they are invoked for the first time. What it really means is that commands are hashed the first time a path search finds them. If you have only HASH_CMDS, then "a path search finds" just the single command you invoked. If you tend to be using one, or a few, commands repeatedly, and never invoke anything else, this is all you need to avoid path search overhead for commands that exist. It remains "expensive" to discover that a command does not exist. If you also have HASH_DIRS set, then "a path search finds" every entry in every directory that is searched. This eliminates the search overhead for any external command you might use in the future. In order to avoid the expense of a useless search when for example you make a typo, the assumption is made that if the command is not already in the cache then it must not be in any part of the path that has previously been searched. The whole search-and-cache process is short-circuited. This really is the intended behavior, because for most people most of the time new commands do not appear in the path during a shell session. It's also the reason that HASH_EXECUTABLES_ONLY eventually got added, because the "every entry in every directory" part tends to be too aggressive for some path elements. Historically, HASH_CMDS predates HASH_DIRS by several years, and the documentation for the former still uses the wording that encompassed that state.