Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] 'exec' runs shell functions and builtins
- X-seq: zsh-workers 41470
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [BUG] 'exec' runs shell functions and builtins
- Date: Thu, 27 Jul 2017 10:02:06 +0100
- Cms-type: 201P
- In-reply-to: <CAH+w=7ZhGm6b-5X+ySsn_VYwUXYRvTG-C_=taC2a0mnjS+sODg@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <fd2a215e-5832-f135-c69d-a1f4e1a6c99e@inlv.org> <CGME20170726174645epcas4p4a4e5eb03651c6e4e3509c19c1408e0e6@epcas4p4.samsung.com> <CAH+w=7ZhGm6b-5X+ySsn_VYwUXYRvTG-C_=taC2a0mnjS+sODg@mail.gmail.com>
On Wed, 26 Jul 2017 10:46:06 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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,
Messages sorted by:
Reverse Date,
Date,
Thread,
Author