Re: while /usr/bin/read
am 29.03.2008 20:37:01 von spcecdt
In article , pk wrote:
>Barry Margolin wrote:
>
>> Which, of course, leads to the next question: why is there a
>> /usr/bin/read command, if it doesn't work?
....
>> I believe the answer is that POSIX has a silly requirement that every
>> shell built-in have a corresponding external command.
>
>POSIX does say something, but not so strict.
>If I read the standard correctly, there is a distinction between "special
>built-ins" and "regular built-ins". It seems that "read" falls into the
>latter category, for which the standard states that they "are not required
>to be actually built into the shell on the implementation" (while special
>built-ins, IIUC, are required to be truly "built-in").
>On the other hand, although the standard defines them as "regular
>built-ins", I've never seen a /bin/cd or a /bin/alias (which nonetheless
>might exist in some implementations, although I can't imagine why an
>implementation would provide such external commands).
Under UnixWare:
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/alias
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/bg
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/cd
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/command
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/fc
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/fg
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/getopts
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/hash
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/jobs
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/read
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/type
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/ulimit
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/umask
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/unalias
-r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/wait
My understanding is that this is based on a (perhaps mis-)reading
of POSIX requirements.
John
--
John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/
Re: while /usr/bin/read
am 30.03.2008 13:25:59 von PK
John DuBois wrote:
> Under UnixWare:
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/alias
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/bg
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/cd
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/command
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/fc
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/fg
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/getopts
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/hash
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/jobs
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/read
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/type
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/ulimit
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/umask
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/unalias
> -r-xr-xr-x 1 bin bin 643 Apr 3 1998 /bin/wait
>
> My understanding is that this is based on a (perhaps mis-)reading
> of POSIX requirements.
Ok, this got me curious enough to do some research. I found an old thread
(1998) on comp.unix.questions (http://tinyurl.com/39l7da) where Chet Ramey
(bash developer/mantainer) said
"POSIX.2 requires that `regular' builtins also be available as executable
commands in the file system, so they can be the target of the exec*(2)
family of system calls and used by programs such as env, find, or xargs.
They don't have to do anything, but they must be present."
I then googled for the POSIX.2 standard, which, according to the opengroup
POSIX FAQs (http://www.opengroup.org/austin/papers/posix_faq.html), doesn't
exist anymore. The closest thing to POSIX.2 (according to
http://www.unixguide.net/unix/bash/A9.shtml) I could find was the SUSv2,
which however does not state the above requirement. So I guess that
requirement got lost somewhere during the sequence of the various
standards.
If someone has more info, I'd like to know more.
--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
Re: while /usr/bin/read
am 30.03.2008 13:50:53 von Sven Mascheck
pk wrote:
> The closest thing to POSIX.2 [...] I could find was the SUSv2,
The latest version is SUSv3 [1], and there you'll find
"Shell & Utilities, Introduction, Built-In Utilities" [2],
which states:
| However, all of the standard utilities, including the regular built-ins
| in the table, but not the special built-ins described in "Special
| Built-In Utilities", shall be implemented in a manner so that they can
| be accessed via the exec family of functions as defined in the System
| Interfaces volume of IEEE Std 1003.1-2001 and can be invoked directly by
| those standard utilities that require it ( env, find, nice, nohup, time,
| xargs).
[1] http://www.opengroup.org/onlinepubs/009695399/
(register with name and email)
[2] http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_ chap01.html#tag_01_13
Re: while /usr/bin/read
am 30.03.2008 14:18:04 von PK
Sven Mascheck wrote:
> | However, all of the standard utilities, including the regular built-ins
> | in the table, but not the special built-ins described in "Special
> | Built-In Utilities", shall be implemented in a manner so that they can
> | be accessed via the exec family of functions as defined in the System
> | Interfaces volume of IEEE Std 1003.1-2001 and can be invoked directly by
> | those standard utilities that require it ( env, find, nice, nohup, time,
> | xargs).
Ahh, then that bit somewhere always escaped my searches inside the standard.
I guess this rounds off the debate.
Many thanks!
--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.