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: James Youngman
Subject: Re: Replacements for regular shell builtins
Date: Mon, 21 Feb 2005 22:21:51 +0000
User-agent: Mutt/1.3.28i

On Mon, Feb 21, 2005 at 12:48:31PM -0800, Paul Eggert wrote:
> Eric Blake <address@hidden> writes:
> 
> > POSIX XRAT also mentions that the simplest implementation for finding
> > regular builtins via exec is to have each builtin utility also be the
> > 8-byte file:
> > $0 "$@"
> 

[...]

> 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.


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?

[*] OK, not infinite, but I think lots of grinding followed by an
unhelpful error message about lack of memory or failure to fork is not
an ideal failure mode.

If these commands were part of the Bash implementation (or, strictly,
just that we could rely on the presence of Bash), the scripts could
say:

#! /usr/bin/env bash
builtin true || exit 127
builtin "$0" "$@"

This has the advantage of avoiding infinite recursion and being
insensitive to the installation location of bash.  I think that when
these scripts work they will do the right thing, and when Bash is not
installed they will return an exit status which is consistent with the
shell not being able to find the command at all.

My only remaining worry though is, does this sort of implementation do
the right thing if $IFS is set to a funny value?   

Regards,
James.





reply via email to

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