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=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5150 invoked from network); 28 Aug 2020 05:41:38 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Aug 2020 05:41:38 -0000 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:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=anu6W0fkH4I3o7fQfv5ibGibgddHCaV9JUI9b0ma2no=; b=gadSsnS1INeicpg6+dq+SFm09n Up82qtDg/4s8sabMddJRlGZPHETRN6fvgB663xHM3logYgf+3KYKG+vtSEvM/aPqhZgT6QFZSYleZ mx2L1XrD6o0TboijpnIumQ2lNKPnLAH+MHwjGuA8Fjp1XrRoRVZKh77uH1tC/7fs+FoDbOu6NbPDJ 65fwC5iTrw/SqoHwojFDKWj7j81Qoxb5RtxeWTjP+DFIvnOQcZAXMBjznPjZjBDy53grwwfe5FwZY sbaYPU6HDkk6V/UviHSDptqSXRnGcD2kVU/LS6bHdZgTTd/hK9PwnQVvFF3Nr+j71MFQ2cBzzvc/I MsQzwMTQ==; Received: from authenticated user by zero.zsh.org with local id 1kBX8m-00083V-KC; Fri, 28 Aug 2020 05:41:32 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f172.google.com) smtp.remote-ip=209.85.167.172; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=skipped; arc=none Received: from mail-oi1-f172.google.com ([209.85.167.172]:32943) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kBX8U-0007tn-5R; Fri, 28 Aug 2020 05:41:15 +0000 Received: by mail-oi1-f172.google.com with SMTP id k25so1245104oij.0 for ; Thu, 27 Aug 2020 22:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=anu6W0fkH4I3o7fQfv5ibGibgddHCaV9JUI9b0ma2no=; b=CP7pIUsQIDZXW/Rcvx5JvsWInt0pRZCcuZnj0BU8y9CYE/Pesh92k11P7GphEU782y JXXMarBIg1nEB6uTR/fPrc7sc7al1kliU2px14yNniNhCrsUEo8LFJVVjiVY9dl011MK ehBedARkQk5fkfM0+D0/uJx5bUdJp4Sp+qRVljrHJdODCQClmPrX/T801ALK4iSMqib5 lsTKbQWinUwAPvOdRypCVpqvdJ93dyk5LMxttfSDq+fjQqCo/4WFSy0OMfYwMn0sLmr8 PBlXOsZ/FR755qn/xMzcg1sjPsRV41X/WxiUDi4wX8WrbNfmQA6Bow63oRWUNJuUVLtR MHmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=anu6W0fkH4I3o7fQfv5ibGibgddHCaV9JUI9b0ma2no=; b=Fpq1YaE7HSGUeYFNcImjy7olGOdMDFUFmgtRQ7cnMmB1ENvvslPK430KcA1NAw8r9R vtiJ4uS0TZxclAP2I9fZr7hgCXnOA9gfncBuN6ODkWsGebN5Qmr5RFUW97dRnOFMP3E1 NXyWzkKIhF6JVT0lcmtv7xKfcbyP68GsCqNIWaf70cuZm58YvPJeAhd2kGhZ3NdCsLoN uY13xY3B/6pZAsX0LJG32kk7ZNAVUMg+p5uzfjKx7zvF6X6BdfNrIxj53nBzocQ+gbXH nGrtYLYIwHtELI3ynGPINCwlGG9WkFXi+4mqF9NJ/18qJzgrkNzr2HFlRykxiAeBNQpE SmQQ== X-Gm-Message-State: AOAM531e66YTM3SafjctkOQDwMN4rB+IsgnQSMr/1IZmL+QQlMLOeCGN f06OFh2iUmmMPYmTO0YuGHzHzivF0KsdHx3zi7Ayq4CHfxIURQ== X-Google-Smtp-Source: ABdhPJz9TtSTPgrFSYM1m242BbBKLxTqGTQ9Oz9KB51+JqK7JU0c9k2wufeqfhMui2HVOnSMLWUl/Fc4hodq0pdWBr4= X-Received: by 2002:aca:d44d:: with SMTP id l74mr31725oig.173.1598593271686; Thu, 27 Aug 2020 22:41:11 -0700 (PDT) MIME-Version: 1.0 From: Bart Schaefer Date: Thu, 27 Aug 2020 22:41:00 -0700 Message-ID: Subject: Minor details of command_not_found_handler To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47345 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: Doc says: ... If the function wishes to mimic the behaviour of the shell when the command is not found, it should print the message `command not found: cmd' to standard error and return status 127. Except that does not really mimic the behavior. Interactive shells print e.g.: zsh: command not found: notacommand and non-interactive shells add a line number: zsh:1: command not found: notacommand This almost does it: print -u2 -r -- "${functrace[1]:-$ZSH_ARGZERO}: command not found: $1" return 127 The nit being that $functrace[1] for a login shell contains "-zsh" rather than "zsh", and of course includes the line number whether or not the shell is interactive. One thing that the doc fails to mention is that, even when function_argzero is set, $0 inside command_not_found_handler is the same as $1 (i.e., the name of the not-found command). However, %N for prompt expansion is "command_not_found_handler".