From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Minor details of command_not_found_handler
Date: Thu, 27 Aug 2020 22:41:00 -0700 [thread overview]
Message-ID: <CAH+w=7aUeoTJFJiEqZYMoa0D6StxTfZGraUYADJYWbuu1uSC4A@mail.gmail.com> (raw)
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".
next reply other threads:[~2020-08-28 5:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-28 5:41 Bart Schaefer [this message]
2020-08-28 8:21 ` Roman Perepelitsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7aUeoTJFJiEqZYMoa0D6StxTfZGraUYADJYWbuu1uSC4A@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).