zsh-workers
 help / color / mirror / code / Atom feed
* Minor details of command_not_found_handler
@ 2020-08-28  5:41 Bart Schaefer
  2020-08-28  8:21 ` Roman Perepelitsa
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2020-08-28  5:41 UTC (permalink / raw)
  To: Zsh hackers list

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".


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-28  8:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28  5:41 Minor details of command_not_found_handler Bart Schaefer
2020-08-28  8:21 ` Roman Perepelitsa

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).