Only invocation by program name mapped install to the internal ginstall
name. Apply the mapping to explicit program selection as well.
* src/coreutils.c (main, launch_program): Move the name mapping into
launch_program so that all callers use it.
* tests/misc/coreutils.sh: Compare --coreutils-prog=install with
--coreutils-prog=ginstall.
* src/local.mk: Manage the install<->ginstall mapping.
---
src/coreutils.c | 11 +++++------
src/local.mk | 14 +++++++-------
tests/misc/coreutils.sh | 6 ++++++
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/src/coreutils.c b/src/coreutils.c
index 9701a5b48..26a43ce64 100644
--- a/src/coreutils.c
+++ b/src/coreutils.c
@@ -70,7 +70,6 @@ Execute the PROGRAM_NAME built-in program with the given
PARAMETERS.\n\
oputs (VERSION_OPTION_DESCRIPTION);
#ifdef SINGLE_BINARY
-/* XXX: Ideally we'd like to present "install" here, not "ginstall". */
char const *prog_name_list =
# define SINGLE_BINARY_PROGRAM(prog_name_str, main_name) " " prog_name_str
# include "coreutils.h"
@@ -100,6 +99,11 @@ launch_program (char const *prog_name, int prog_argc, char
**prog_argv)
return;
#ifdef SINGLE_BINARY
+ /* Also accept the internal name for "install", as "ginstall"
+ was the only accepted --coreutils-prog argument from v8.23 to v9.12. */
+ if (streq (prog_name, "ginstall"))
+ prog_name = "install";
+
if (false);
/* Look up the right main program. */
# define SINGLE_BINARY_PROGRAM(prog_name_str, main_name) \
@@ -132,11 +136,6 @@ main (int argc, char **argv)
char *prog_name = last_component (argv[0]);
int optc;
- /* Map external name to internal name. */
- char ginstall[] = "ginstall";
- if (streq (prog_name, "install"))
- prog_name = ginstall;
-
/* If this program is called directly as "coreutils" or if the value of
argv[0] is an unknown tool (which "coreutils" is), we proceed and parse
the options. */
diff --git a/src/local.mk b/src/local.mk
index 4bdc54f0a..e7aed1d46 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -778,9 +778,9 @@ src/speedlist.h: src/termios.c lib/config.h src/speedgen
# Generates a list of macro invocations like:
# SINGLE_BINARY_PROGRAM(program_name_str, main_name)
-# once for each program list on $(single_binary_progs). Note that
-# for [ the macro invocation is:
+# once for each program in $(single_binary_progs), using its installed name:
# SINGLE_BINARY_PROGRAM("[", lbracket)
+# SINGLE_BINARY_PROGRAM("install", ginstall)
DISTCLEANFILES += src/coreutils.h
src/coreutils.h: Makefile
$(AM_V_GEN)rm -f $@
@@ -788,11 +788,11 @@ src/coreutils.h: Makefile
$(AM_V_at)for prog in x $(single_binary_progs); do \
test $$prog = x && continue; \
prog=`basename $$prog`; \
- main=`if test $$prog = '['; then \
- echo lbracket; \
- else \
- echo $$prog; \
- fi`; \
+ main=$$prog; \
+ case $$prog in \
+ '[') main=lbracket ;; \
+ ginstall) prog=install ;; \
+ esac; \
echo "SINGLE_BINARY_PROGRAM(\"$$prog\", $$main)"; \
done | sort > $@t
$(AM_V_at)chmod a-w $@t
diff --git a/tests/misc/coreutils.sh b/tests/misc/coreutils.sh
index d6745cd15..73cc177dc 100755
--- a/tests/misc/coreutils.sh
+++ b/tests/misc/coreutils.sh
@@ -27,6 +27,12 @@ echo 'y' > exp &&
coreutils --coreutils-prog=yes | head -n10 | uniq > out || framework_failure_
compare exp out || fail=1
+# The installed name 'install' selects the ginstall built-in.
+if coreutils --coreutils-prog=ginstall --version > exp 2>/dev/null; then
+ coreutils --coreutils-prog=install --version > out || fail=1
+ compare exp out || fail=1
+fi
+
# Ensure empty arg is rejected
returns_ 1 coreutils $unset_command || fail=1
--
2.56.0