Date:        Tue, 25 Jul 2017 22:53:40 +0000 (UTC)
    From:        Thorsten Glaser <tg...@mirbsd.org>
    Message-ID:  <pine.bsm.4.64l.1707252244070.2...@herc.mirbsd.org>

  | This specifically means that builtins MAY be made available
  | to exec, and that that’s an expected modus operandi.

It means nothing of the kind.   The System Interfaces volume of POSIX.1-2008
is the part that defines the system calls.

What the text you quoted is saying (if you had quoted it all) is that
all of the built-in utilities (except the special built-ins) must be
able to be accessed by execle(2) (and its sibling interfaces.)

Note not may, must.

Aside from the possibility that the sh exec special-builtin might be
intended to make an exec*() system call (the spec does not say that)
it has nothing whatever to do with the System Interfaces volume.

  | So whether the program code implementing the utility is part
  | of the same on-disc executable file as the shell, or even
  | implemented in terms of shell structures, is a transparent
  | implementation detail, as long as the shell replaces itself
  | with that utility (which boils down to just never returning
  | to the invoking shell and “without creating a new process”).

That's true for echo, true, false, ... and all that set that are
built in (usually) just for performance.   But something like
        exec wait %1
is not going to work as intended at all if it starts a new process
(which will have no idea what %1 means, even if it does remain the
parent of that process, or set of processes).

  | Heck, you can exec a function!

That is where we started.   That is, that is the question.  Can you?
Some shells allow it, most do not.  Then should that be required,
permitted, or banned...

kre

ps: the quoted text was the subject of some discussion recently amongst
NetBSD developers, and after the laughter/shock abated, it was decided
that there's no way that NetBSD is going to pollute its filesystem with
useless exec'able commands like wait, jobs, fg, ...    If POSIX continues
to require that nonsense, then that's just another way we will deliberately
not conform.


Reply via email to