$ size src/coreutils-prev
       text    data     bss     dec     hex filename
    1476092    7348 2191936 3675376  3814f0 src/coreutils-prev
    $ size src/coreutils
       text    data     bss     dec     hex filename
    1474612    7348 2191968 3673928  380f48 src/coreutils

* src/local.mk (noinst_HEADERS): Add src/true.h.
(src_false_LDADD): Organize with the rest of the reused programs. Use
$(src_true_LDADD) instead of $(LDADD).
(src_true_SOURCES, src_false_SOURCES): New variables.
* build-aux/gen-single-binary.sh (override_single): Map 'false' to
'true'.
* src/false.c: Remove file.
* po/POTFILES.in: Remove src/false.c.
* cfg.mk (_src): Match src/true-false.c and src/true-true.c.
* src/coreutils-false.c: New file.
* src/true-false.c: Likewise.
* src/true-true.c: Likewise.
* src/true.h: Likewise.
* src/true.c: Include true.h.
(EXIT_STATUS): Always define the macro to use the value of the TRUE_MODE
variable.
(PROGRAM_NAME): Likewise.
* NEWS: Mention the improvement.
---
 NEWS                           |  4 ++--
 build-aux/gen-single-binary.sh |  1 +
 cfg.mk                         |  2 +-
 po/POTFILES.in                 |  1 -
 src/coreutils-false.c          | 31 +++++++++++++++++++++++++++++++
 src/false.c                    |  2 --
 src/local.mk                   |  7 ++++++-
 src/true-false.c               |  2 ++
 src/true-true.c                |  2 ++
 src/true.c                     | 13 +++----------
 src/true.h                     | 10 ++++++++++
 11 files changed, 58 insertions(+), 17 deletions(-)
 create mode 100644 src/coreutils-false.c
 delete mode 100644 src/false.c
 create mode 100644 src/true-false.c
 create mode 100644 src/true-true.c
 create mode 100644 src/true.h

diff --git a/NEWS b/NEWS
index 19fb04ce1..73c7af9d1 100644
--- a/NEWS
+++ b/NEWS
@@ -80,8 +80,8 @@ GNU coreutils NEWS                                    -*- 
outline -*-
 ** Build-related
 
   The multi-call binary built with configure --enable-single-binary
-  in size by around 9KB through the more efficient reuse of the 'test' utility
-  by '['.
+  in size by around 10KB through the more efficient reuse of the 'test' utility
+  by '[' and the 'true' utility by 'false'.
 
   configure no longer accepts the --with-linux-crypto option, which allowed
   cksum, md5sum, and sha*sum to use the Linux AF_ALG API.  This API will be
diff --git a/build-aux/gen-single-binary.sh b/build-aux/gen-single-binary.sh
index 8d9fb0d52..33a431b1c 100755
--- a/build-aux/gen-single-binary.sh
+++ b/build-aux/gen-single-binary.sh
@@ -76,6 +76,7 @@ override_single() {
 }
 # This is for the '[' program.  Automake transliterates '[' and '/' to '_'.
 override_single _ test
+override_single false true
 override_single dir ls
 override_single vdir ls
 override_single arch uname
diff --git a/cfg.mk b/cfg.mk
index 2848d6fdc..90e6a21d1 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -931,7 +931,7 @@ exclude_file_name_regexp--sc_system_h_headers = \
 
 _src := (false|chown-(chgrp|chown)
 _src := $(_src)|ls-(dir|ls|vdir)|make-prime-list|tac-pipe|test-(lbracket|test)
-_src := $(_src)|uname-(arch|uname))
+_src := $(_src)|true-(false|true)|uname-(arch|uname))
 _gl_src = (xdecto.max|cl-strtold)
 exclude_file_name_regexp--sc_require_config_h_first = \
   (^lib/buffer-lcm\.c|gl/lib/$(_gl_src)\.c|src/$(_src)\.c)$$
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0c9dfe810..905de6e26 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -63,7 +63,6 @@ src/expand-common.c
 src/expand.c
 src/expr.c
 src/factor.c
-src/false.c
 src/find-mount-point.c
 src/fmt.c
 src/fold.c
diff --git a/src/coreutils-false.c b/src/coreutils-false.c
new file mode 100644
index 000000000..9765ea1ab
--- /dev/null
+++ b/src/coreutils-false.c
@@ -0,0 +1,31 @@
+/* false -- wrapper to true with the right true_mode.
+   Copyright (C) 2026 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+#include "system.h"
+
+#include "true.h"
+/* Ensure that the main for true is declared even if the tool is not being
+   built in this single-binary. */
+int single_binary_main_true (int argc, char **argv);
+int single_binary_main_false (int argc, char **argv);
+
+int
+single_binary_main_false (int argc, char **argv)
+{
+  true_mode = TRUE_FALSE;
+  return single_binary_main_true (argc, argv);
+}
diff --git a/src/false.c b/src/false.c
deleted file mode 100644
index bc9c703a5..000000000
--- a/src/false.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define EXIT_STATUS EXIT_FAILURE
-#include "true.c"
diff --git a/src/local.mk b/src/local.mk
index 1a6079d69..d7d6ae509 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -67,6 +67,7 @@ noinst_HEADERS =              \
   src/temp-stream.h            \
   src/term-sig.h               \
   src/test.h                   \
+  src/true.h                   \
   src/uname.h                  \
   src/wc.h
 
@@ -141,7 +142,7 @@ src_env_LDADD = $(LDADD)
 src_expand_LDADD = $(LDADD)
 src_expr_LDADD = $(LDADD)
 src_factor_LDADD = $(LDADD)
-src_false_LDADD = $(LDADD)
+# See src_false_LDADD below
 src_fmt_LDADD = $(LDADD)
 src_fold_LDADD = $(LDADD)
 src_getlimits_LDADD = $(LDADD)
@@ -224,6 +225,7 @@ src_yes_LDADD = $(LDADD)
 
 # Synonyms.  Recall that Automake transliterates '[' and '/' to '_'.
 src___LDADD = $(src_test_LDADD)
+src_false_LDADD = $(src_true_LDADD)
 src_dir_LDADD = $(src_ls_LDADD)
 src_vdir_LDADD = $(src_ls_LDADD)
 src_chgrp_LDADD = $(src_chown_LDADD)
@@ -421,6 +423,9 @@ src_mknod_SOURCES = src/mknod.c $(selinux_sources)
 src_df_SOURCES = src/df.c src/find-mount-point.c
 src_stat_SOURCES = src/stat.c src/find-mount-point.c
 
+src_true_SOURCES = src/true.c src/true-true.c
+src_false_SOURCES = src/true.c src/true-false.c
+
 src_uname_SOURCES = src/uname.c src/uname-uname.c
 src_arch_SOURCES = src/uname.c src/uname-arch.c
 
diff --git a/src/true-false.c b/src/true-false.c
new file mode 100644
index 000000000..021e5b8d3
--- /dev/null
+++ b/src/true-false.c
@@ -0,0 +1,2 @@
+#include "true.h"
+enum true_modes true_mode = TRUE_FALSE;
diff --git a/src/true-true.c b/src/true-true.c
new file mode 100644
index 000000000..93be3e436
--- /dev/null
+++ b/src/true-true.c
@@ -0,0 +1,2 @@
+#include "true.h"
+enum true_modes true_mode = TRUE_TRUE;
diff --git a/src/true.c b/src/true.c
index 6603177f4..d383c7976 100644
--- a/src/true.c
+++ b/src/true.c
@@ -18,17 +18,10 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include "system.h"
+#include "true.h"
 
-/* Act like "true" by default; false.c overrides this.  */
-#ifndef EXIT_STATUS
-# define EXIT_STATUS EXIT_SUCCESS
-#endif
-
-#if EXIT_STATUS == EXIT_SUCCESS
-# define PROGRAM_NAME "true"
-#else
-# define PROGRAM_NAME "false"
-#endif
+#define EXIT_STATUS (true_mode != TRUE_TRUE)
+#define PROGRAM_NAME (true_mode == TRUE_TRUE ? "true" : "false")
 
 #define AUTHORS proper_name ("Jim Meyering")
 
diff --git a/src/true.h b/src/true.h
new file mode 100644
index 000000000..7fdd28e8f
--- /dev/null
+++ b/src/true.h
@@ -0,0 +1,10 @@
+enum true_modes
+{
+  /* This is for the 'true' program.  */
+  TRUE_TRUE,
+
+  /* This is for the 'false' program.  */
+  TRUE_FALSE
+};
+
+extern enum true_modes true_mode;
-- 
2.55.0


Reply via email to