bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replacements for regular shell builtins


From: Eric Blake
Subject: Re: Replacements for regular shell builtins
Date: Wed, 23 Feb 2005 06:43:53 -0700
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to James Youngman on 2/21/2005 3:21 PM:
> 
>>For these utilities we can simply insist on a POSIX shell.  Pedants
>>(who are the only audience here, really) won't object to such a
>>requirement.

On the bug-bash list, Chet Ramey pointed out to me that a POSIX shell is
not required to implement those 17 utilities as built-ins; it only
requires that the POSIX-compliant version those 17 utilities be
successfully found without searching PATH, and that any side-effects to
the current environment take place correctly.  Thus, most of the 17
utilities must be builtins to be fully compliant (for example, cd, read,
etc.), but several of them (true, false, and newgrp) have no requirements
to have side effects on the current environment.  So, while we can cobble
together a simple script for the remaining utilities, coreutils really
needs a fully-compliant newgrp since Chet was unwilling to provide it as a
bash builtin.

> 
> I'm not objecting to the approach, but how will we prevent infinite[*]
> recursion if the POSIX shell is replaced with a non-POSIX shell?

We don't even have to assume bash.  The following approach worked for me,
even on cygwin where /bin/sh is ash and is not very compliant:

#! /bin/sh
test x"$INSIDE_COREUTILS" = xyes && exit 127
INSIDE_COREUTILS=yes
export INSIDE_COREUTILS
`basename $0` "$@"

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCHIiY84KuGfSFAYARAtbhAJ96rVxHM9MC6hoSDCJ3SHg0ALhehQCfQ4uU
r4NkGeTf+hSkLq+QKOnUWNU=
=61ih
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]