Bug 291686 - Intrinsic Shell Utilities shouldn't have an executable if it is useless
Summary: Intrinsic Shell Utilities shouldn't have an executable if it is useless
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: Dag-Erling Smørgrav
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-15 13:21 UTC by Benjamin Takacs
Modified: 2026-02-16 01:38 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Takacs 2025-12-15 13:21:26 UTC
There are some useless executables installed on FreeBSD, like alias, bg, cd, fg, …. These are part of the Intrinsic Utilities [0] as defined by POSIX, as they only exist to manipulate the *current* shells execution environment and are useless when spawned on its own. That's a reason why they don't have to be provided as executables [1]. Only kill is required as an executable.

I haven't checked if another of those intrinsic utilities is useful to have as executable. But the useless ones should get removed.


[0]: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap01.html#tag_18_07
[1]: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap01.html#tag_18_06
Comment 1 Ed Maste freebsd_committer freebsd_triage 2025-12-15 13:51:46 UTC
For reference these were originally introduced in commit b107f944adcc3cb203dd283c45c7be193b3f8ada with the message

    POSIX requires these shell builtins to also exist as totally pointless
    external commands.  Since they serve no useful purpose, it's OK that their
    implementation is not the most efficient possible.
Comment 2 Alexander Ziaee freebsd_committer freebsd_triage 2025-12-15 15:19:12 UTC
Everybody wants to remove utilities that don't seem useful to them for one reason or another, because they're so visible, but they are not a problem.

What would be actually useful is to remove unused functions, or other forms of dangling stuff from past removals. That would be actually improving the maintainability of the code base, and paying real technical debt.

There is more code on the table to be removed from the latter than the former.
Comment 3 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2025-12-15 18:10:25 UTC
These are required by POSIX and barely take up any space.
Comment 4 Ed Maste freebsd_committer freebsd_triage 2025-12-15 18:14:34 UTC
They are not required:

1.6 Built-In Utilities
...
However, all of the standard utilities other than:
...
    The intrinsic utilities named in Intrinsic Utilities, except for kill

shall be implemented, regardless of whether they are also implemented as regular built-ins, 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-2024 and can be invoked directly by those standard utilities that require it (env, find, nice, nohup, time, xargs).

1.7 Intrinsic Utilities

As described in 2.9.1.4 Command Search and Execution, intrinsic utilities are not subject to a PATH search during command search and execution. The utilities named in Intrinsic Utilities shall be intrinsic utilities.

Table: Intrinsic Utilities

alias
bg
cd
command
fc
fg
getopts
hash
jobs
kill
read
type
ulimit
umask
unalias
Comment 5 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2025-12-15 18:20:56 UTC
Ah, that's new in the 2024 edition:

https://austingroupbugs.net/view.php?id=854

So they _were_ required until last year, but we can now remove at least some of them.
Comment 6 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2025-12-15 18:40:39 UTC
https://reviews.freebsd.org/D54239
Comment 7 commit-hook freebsd_committer freebsd_triage 2025-12-19 17:17:06 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4100bd6caa66434bc901ca48d7364bc2b5fe2cfd

commit 4100bd6caa66434bc901ca48d7364bc2b5fe2cfd
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-12-19 17:13:23 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-12-19 17:15:40 +0000

    usr.bin: Remove intrinsic utilities

    These utilities can only function correctly if implemented as shell
    builtins and exist only because POSIX previously required them.  As of
    POSIX 2024, they have all been reclassified as intrinsic utilities and
    are no longer required to exist in PATH.  We can therefore retire them.
    Cf. XBD 1.7, XRAT C.1.8, Austin Group bug 854.

    Note that kill(1) is also considered an intrinsic utility (because
    only the shell can interpret job IDs correctly), but we have a working
    standalone implementation, which we will keep.

    PR:             291686
    Relnotes:       yes
    Reviewed by:    imp, emaste
    Differential Revision:  https://reviews.freebsd.org/D54239

 ObsoleteFiles.inc                       | 17 +++++++++++++++
 share/man/man1/builtin.1                | 38 ++++++++++++++-------------------
 targets/pseudo/userland/Makefile.depend |  1 -
 usr.bin/Makefile                        |  3 +--
 usr.bin/alias/Makefile (gone)           | 19 -----------------
 usr.bin/alias/Makefile.depend (gone)    | 10 ---------
 usr.bin/alias/generic.sh (gone)         |  3 ---
 7 files changed, 34 insertions(+), 57 deletions(-)