Dixi quod… >Martijn Dekker dixit: > >>to be a bug in POSIX terms; 'exec' is supposed to launch a program that >>overlays the current shell[2], implying the program launched by 'exec' >>is always external to the shell. > >The built-in utility is “the program implementing command”, >and, with exec, it is not returning to the shell.
POSIX even provides for that otherplace: The term "built-in" implies that the shell can execute the utility directly and does not need to search for it. An implementation may choose to make any utility a built-in; [… something about special builtins] And: The special built-in utilities in this section need not be provided in a manner accessible via the exec family of functions defined in the System Interfaces volume of POSIX.1-2008. This specifically means that builtins MAY be made available to exec, and that that’s an expected modus operandi. Whether “echo” is a builtin or not is an implementation detail. Heck, things like “true”, “false”, … are (and others can be) implemented in some operating systems by symlinking them to the shell executable (either ksh93 *or* mksh… not even considering busybox). 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”). And we’ve already seen above that the “command” argument to exec may be a builtin especially considering “Command Search and Execution”. Heck, you can exec a function! bye, //mirabilos -- 11:56⎜«liwakura:#!/bin/mksh» also, i wanted to add mksh to my own distro │ i was disappointed that there is no makefile │ but somehow the Build.sh is the least painful built system i've ever seen │ honours CC, {CPP,C,LD}FLAGS properly │ looks cleary like done by someone who knows what they are doing