Dear debian and linux enthusiasts,
Have you ever stopped and wondered:
Are `/usr/bin/[` and `/usr/bin/test` truly unique across all unices?
Dear debian and linux enthusiasts,
Have you ever stopped and wondered:
Are `/usr/bin/[` and `/usr/bin/test` truly unique across all unices?
# diff /usr/bin/\[ /usr/bin/test
Binary files /usr/bin/[ and /usr/bin/test differ
# ls /usr/bin/\[
-rwxr-xr-x 1 root root 67K Sep 20 2022 '/usr/bin/['
# ls /usr/bin/test
-rwxr-xr-x 1 root root 59K Sep 20 2022 /usr/bin/test
# sys.distro
Debian GNU/Linux 12 \n \l
#
I can think of one single reason to keep them separate:
/usr/bin/[ needs to ensure there’s a closing ].
test doesn't.
If that's the only reason,
then the two commands must be sharing a huge chunk of the same DNA!
So, why keep them separate?
Is this about some old Unix tradition?
an optimization somewhere somehow?
Le 11/18/24 à 11:50, tomas@tuxteam.de a écrit :
Help yourseof :)
https://sources.debian.org/src/coreutils/
(Of course, apt-get source coreutils would do the same).
Cheers
Thank you tomas,
Help yourseof :)
https://sources.debian.org/src/coreutils/
(Of course, apt-get source coreutils would do the same).
Cheers
Am 18.11.2024 um 11:45 schrieb Yassine Chaouche:
Dear debian and linux enthusiasts,
Have you ever stopped and wondered:
Are `/usr/bin/[` and `/usr/bin/test` truly unique across all unices?
interesting question (and observation below). I can't say I ever really cared, and I'm not even sure now. But:
$ LANG=C /usr/bin/\[ --help | head -n 2
Usage: test EXPRESSION
or: test
is also nice to find.
Unfortunately, I'm not brilliant at all.
But I'm eager to see if Greg has something to educate us ;-)
On Mon, Nov 18, 2024 at 11:57:05 +0100, Arno Lehmann wrote:...
Unfortunately, I'm not brilliant at all.
But I'm eager to see if Greg has something to educate us ;-)
POSIX doesn't care whether you ship separate binary files or a single
binary file
... find that the two
programs shared a single binary file, and either used a hard link or
a symbolic link from one to the other. That was fashionable in the
past, primarily as a means of reducing disk space usage.
In recent years, GNU has tried to do away with the whole "this program
may be invoked by any of the following names, and it changes it behavior based on which name it finds in argv[0]" approach. From <https://www.gnu.org/prep/standards/standards.html#Standards-for-Interfaces-Generally>:
If you look around a bit, you'll find that commands which *used* to share
a common file (grep/egrep/fgrep, gzip/gunzip/zcat) have started shipping
a single compiled binary file and a set of wrapper shell scripts for
the alternative names. E.g.:
A wrapper script can't be used to differentiate test and [, however,
because of the way the final argument is treated.
So, why keep them separate?
Is this about some old Unix tradition?
an optimization somewhere somehow?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 03:57:23 |
Calls: | 10,387 |
Calls today: | 2 |
Files: | 14,061 |
Messages: | 6,416,778 |