zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Bart Schaefer <schaefer@brasslantern.com>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] 'exec' runs shell functions and builtins
Date: Thu, 27 Jul 2017 10:02:06 +0100	[thread overview]
Message-ID: <20170727100206.4dda10d9@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <CAH+w=7ZhGm6b-5X+ySsn_VYwUXYRvTG-C_=taC2a0mnjS+sODg@mail.gmail.com>

On Wed, 26 Jul 2017 10:46:06 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> AFAIK zsh has always had this behavior.  It also allows for example
> "exec builtin echo" as well as "builtin exec echo" etc.  What would
> POSIX say that
>     exec command echo foo
> should do?  It's relatively easy to stop "exec" from finding functions
> and builtin commands, but I think fairly painful to get it to ignore
> other "precommand modifier" tokens.  Even after PWS's 41464 the above
> example runs /bin/echo whereas I think the POSIX expectation would be
> to report "command: command not found".

This isn't what I get:

% (setopt posixbuiltins; exec command echo foo)
zsh: command not found: command
% cat ~/bin/builtin
#!/bin/sh
echo External command named $0
% (setopt posixbuiltins; exec builtin echo)
External command named /export/home/pws/bin/builtin

There's no further processing of the arguments when we find an exec
with posixbuiltins set, so the above is what I'd expect.

pws

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 99b1dd4..0e8580d 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -679,7 +679,10 @@ See ifzman(the section `Precommand Modifiers' in zmanref(zshmisc))\
 ifnzman(noderef(Precommand Modifiers)).
 
 If the option tt(POSIX_BUILTINS) is set, var(command) is never
-interpreted as a shell builtin command or shell function.
+interpreted as a shell builtin command or shell function.  This
+means further precommand modifiers such as tt(builtin) and
+tt(noglob) are also not interpreted within the shell.  Hence
+var(command) is always found by searching the command path.
 
 cindex(redirection, current shell's I/O)
 If var(command) is omitted but any redirections are specified,


  parent reply	other threads:[~2017-07-27  9:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170725221050epcas4p131de822f47289e279c7de12de0d6c127@epcas4p1.samsung.com>
2017-07-25 21:49 ` Martijn Dekker
2017-07-26  9:23   ` Peter Stephenson
2017-07-26  9:27     ` Peter Stephenson
2017-07-26 12:53   ` Peter Stephenson
2017-08-04 15:34     ` Stephane Chazelas
2017-07-26 17:46   ` Bart Schaefer
2017-07-26 17:48     ` Bart Schaefer
2017-07-27  9:02     ` Peter Stephenson [this message]
2017-07-28 17:58       ` Bart Schaefer
2017-08-11 15:10         ` Kamil Dudka
2017-08-11 15:25           ` Peter Stephenson
2017-08-14  7:19             ` Kamil Dudka

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=20170727100206.4dda10d9@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=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).