Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Minor details of command_not_found_handler
- X-seq: zsh-workers 47345
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Minor details of command_not_found_handler
- Date: Thu, 27 Aug 2020 22:41:00 -0700
- Archived-at: <https://zsh.org/workers/47345>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-08/CAH%2Bw%3D7aUeoTJFJiEqZYMoa0D6StxTfZGraUYADJYWbuu1uSC4A%40mail.gmail.com>
- 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
- 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==
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- Sender: zsh-workers-request@xxxxxxx
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".
Messages sorted by:
Reverse Date,
Date,
Thread,
Author