Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Aug 2012 00:30:02 +0200
From:      Jilles Tjoelker <jilles@stack.nl>
To:        "Simon J. Gerraty" <sjg@juniper.net>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Ruslan Ermilov <ru@FreeBSD.org>, "David E. O'Brien" <obrien@FreeBSD.org>
Subject:   Re: svn commit: r238563 - head/gnu/usr.bin/groff/tmac
Message-ID:  <20120822223002.GA41104@stack.nl>
In-Reply-To: <20120821232553.35D4F58085@chaos.jnpr.net>
References:  <201207180557.q6I5vheM034018@svn.freebsd.org> <20120726084903.GA48240@lo0.su> <20120821053519.BD5A158085@chaos.jnpr.net> <20120821222943.GA27203@stack.nl> <20120821232553.35D4F58085@chaos.jnpr.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Aug 21, 2012 at 04:25:53PM -0700, Simon J. Gerraty wrote:
> On Wed, 22 Aug 2012 00:29:44 +0200, Jilles Tjoelker writes:
> >On FreeBSD, the first two statements are partially false. All sh(1)
> >builtins that correspond to utilities specified by POSIX (but not
> >special builtins) have versions accessible to execve() (on 8.x and

> That's interesting, especially for 'cd', though is there any use case in
> which it is actually useful? I'm drawing a blank.

I think the most important reason is to reduce special cases. The POSIX
developers did not want to create a second subset of utilities that are
not available via execve() (the first subset is the special builtins).
The burden on implementations is very low (see src/usr.bin/alias), and
there are some possible use cases:

'cd' will fail if the directory does not exist.
'command -v' and 'command -V' will show information.
'read' will swallow input.
'type', 'umask' and 'ulimit' will show information.

> >older, hash, type and ulimit are missing). This includes cd but not
> >chdir, since chdir is not specified by POSIX. Also, FreeBSD make
> >includes a somewhat arbitrary list of shell builtins, including cd, that
> >cause it to invoke the shell even if there are no metacharacters.

> Yes, I pondered whether something like that might be worthwhile,
> but since a bare 'cd somewhere' all by itself is rather pointless, it
> seemed a corner case.

If it avoids the need to add semicolons for mysterious reasons, that may
be enough reason.

I think make's optimization of executing certain commands directly
instead of passing them to sh should be rather invisible to the user,
particularly if the optimization may be activated or deactivated by
something seemingly innocuous like toggling -j.

It seems not entirely possible to hide the optimization completely as
that would require deeper knowledge of the shell in make. Shell builtins
are usually found before a PATH search and there may be non-standard
shell builtins.

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120822223002.GA41104>