A peculiarity of the GNU Coreutils version of ‘test’ and ‘[‘

The GNU Coreutils version of ‘test’ and ‘[‘ has a peculiar difference. While ‘[‘ is a program and also known as ‘test’, on most systems, it is implemented as a hardlink to ‘test’. However, GNU Coreutils is an exception. Although the two names are derived from the same source code, they are different binaries, with the ‘[‘ binary being larger. The reason for this lies in the behavior of running ‘test’ with a single argument. In POSIX, a single argument is treated as a string, and the behavior is the same as for -n. However, GNU Coreutils has specific restrictions on ‘test’, disallowing options like –help and –version. On the other hand, ‘[‘ can interpret these options without any closing ‘]’. This difference in behavior accounts for the variance in binary size. The ‘test’ binary omits version and help text, resulting in a smaller size. Modern C compilers optimize the code by eliminating dead code sections and dropping unused functions, further reducing the size of the binary. It is worth noting that the handling of a single argument for ‘test’ dates back to V7, where it was documented in the test(1) manual page. While theoretically portable, GNU Coreutils

https://utcc.utoronto.ca/~cks/space/blog/linux/CoreutilsTestPeculiarity

To top