View Issue Details

IDProjectCategoryView StatusLast Update
00006981003.1(2013)/Issue7+TC1Shell and Utilitiespublic2013-05-23 16:37
Reportereblake Assigned To 
PrioritynormalSeverityObjectionTypeError
Status ClosedResolutionRejected 
NameEric Blake
OrganizationRed Hat
User Referenceebb.builtins
SectionXCU 1.6
Page Number2318
Line Number73547
Interp Status---
Final Accepted Text
Summary0000698: shell builtins should not be required to be exec'able
DescriptionThe standard describes a list of utilities that are not special
built-ins, but are typically provided as shell built-ins because they
sometimes or always need particular access to the current shell's
environment in a manner that an exec'able alternative would fail to
have.

Because these particular utilities are already provided by the shell,
and required to be recognized even without a PATH search, some
implementations have proceeded to provide exec'able alternatives by
doing:

$ printf '#!/bin/sh\ncommand "$(basename -- "$0")" "$@"\n' > /usr/bin/alias
$ chmod +x /usr/bin/alias
$ for util in bg cd command false fd fg getopts jobs kill newgrp pwd
read true umask unalias wait; do
 ln /usr/bin/alias /usr/bin/$util
done

However, as discussed in this bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=698670 there was a
question on whether it even makes sense to mandate some of the shell
builtins to be exec-able.

Some of these 17 built-ins are often provided as an exec'able variant
(true and false have no dependency on the current environment ; at
least bash requires newgrp to be exec'able because it does not provide
a built-in variant; pwd is often exec'able because a suid program can
gather information about otherwise-unsearchable directories; kill is
often exec'able with the caveat that the exec'd version cannot honor
%1 job specs the way a built-in can). However, others are rather
pointless as an exec'able version (about the only use I could see for
an exec'able cd is its side-effect of printing the location that a
CDPATH lookup would find; an exec'able fg will always fail; and so
forth).

I propose that implementations still be allowed to provide exec'able
alternatives of these 17 built-ins, as a quality of implementation,
but that the requirement be relaxed to allow for implementations that
do not want to install what would normally be pointless unused shim
file around the built-ins.
Desired ActionAt page 46 line 1442 [XCU 3.83 Built-In Utility], change
Regular built-ins are not required to be actually built into the shell
on the implementation, but they do have special command-search
qualities.


to
Regular built-ins are not required to be actually built into the shell
on the implementation, but some of them do have special command-search
qualities.


At line 1445 [XCU 3.83 Built-In Utility], change
Regular Built-In Utilities are defined in detail in XCU Section
2.9.1.1 (on page 2339).


to
Regular Built-In Utilities are defined in detail in XCU Section 1.6
(on page 2318).


At page 2318 line 73552 [XBD 1.6 Built-In Utilities], change
However, all of the standard utilities, including the regular
built-ins in the table, but not the special built-ins described in
Section 2.14 (on page 2356), 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 POSIX.1-2008 and can be invoked
directly by those standard utilities that require it (env, find, nice,
nohup, time, xargs).


to:
All built-in standard utilities that are neither special built-ins
described in Section 2.14 (on page 2356) nor those with special
command search requirements described in section 2.9.1.1 (on page
2339) 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 POSIX.1-2008 and can be invoked directly by those standard
utilities that require it (env, find, nice, nohup, time, xargs).  It
is unspecified whether the regular built-in utilities with special
command search requirements will be accessible via the exec family of
functions; for the ones that are accessible, they may have limited
behavior when invoked via exec.

TagsNo tags attached.

Activities

eblake

2013-05-16 22:25

manager   bugnote:0001611

I've also noticed some inconsistencies in the various utilities in describing in non-normative text what happens when trying to use these built-ins in subshells or separate execution environments (for example, alias mentions things in RATIONALE, while bg mentions it in APPLICATION USAGE); I am considering auditing them and adding a note that cleans this up as part of this bug.

geoffclare

2013-05-17 09:35

manager   bugnote:0001613

See XRAT C.1.7 for the original POSIX.2 developers' views on this issue.

Don Cragun

2013-05-23 16:36

manager   bugnote:0001626

This was discussed during the May 23, 2013 conference call.
XRAT section C.1.7 clearly states why the authors of this section of the standard decided to require these built-ins to be exec-able. We do not believe that the arguments presented in this change request override the concerns stated by the original authors.

Therefore, we reject this proposed change.

Issue History

Date Modified Username Field Change
2013-05-16 22:22 eblake New Issue
2013-05-16 22:22 eblake Name => Eric Blake
2013-05-16 22:22 eblake Organization => Red Hat
2013-05-16 22:22 eblake User Reference => ebb.builtins
2013-05-16 22:22 eblake Section => XCU 1.6
2013-05-16 22:22 eblake Page Number => 2318
2013-05-16 22:22 eblake Line Number => 73547
2013-05-16 22:22 eblake Interp Status => ---
2013-05-16 22:25 eblake Note Added: 0001611
2013-05-17 09:35 geoffclare Note Added: 0001613
2013-05-23 16:36 Don Cragun Note Added: 0001626
2013-05-23 16:37 Don Cragun Status New => Closed
2013-05-23 16:37 Don Cragun Resolution Open => Rejected