In preparation for more stringent requirements on the dispatcher name.
* src/local.mk (src_coreutils_CPPFLAGS): Pass EXEEXT to the dispatcher.
* src/coreutils.c (main): Recognize dispatcher names with the configured
executable suffix as well as names without it.
* tests/misc/coreutils.sh: Use EXEEXT for the prefixed dispatcher.
---
src/coreutils.c | 4 +++-
src/local.mk | 1 +
tests/misc/coreutils.sh | 4 ++--
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/coreutils.c b/src/coreutils.c
index 07179b912..39ea9c95a 100644
--- a/src/coreutils.c
+++ b/src/coreutils.c
@@ -186,7 +186,9 @@ main (int argc, char **argv)
launch_program (prog_name, argc, argv);
/* Accept a positional program name only when invoked as the dispatcher. */
- bool is_coreutils = str_endswith (prog_name, PROGRAM_NAME);
+ bool is_coreutils = (str_endswith (prog_name, PROGRAM_NAME)
+ || (EXEEXT[0]
+ && str_endswith (prog_name, PROGRAM_NAME EXEEXT)));
size_t nskip = 0;
if (argc >= 2)
{
diff --git a/src/local.mk b/src/local.mk
index e7aed1d46..8f705f075 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -392,6 +392,7 @@ src_test_SOURCES = src/test.c src/test-test.c
nodist_src_coreutils_SOURCES = src/coreutils.h
src_coreutils_SOURCES = src/coreutils.c
+src_coreutils_CPPFLAGS = -DEXEEXT='"$(EXEEXT)"' $(AM_CPPFLAGS)
nodist_src_stty_SOURCES = src/speedlist.h
src_stty_SOURCES = src/stty.c
diff --git a/tests/misc/coreutils.sh b/tests/misc/coreutils.sh
index ee03a7829..c9bd8d916 100755
--- a/tests/misc/coreutils.sh
+++ b/tests/misc/coreutils.sh
@@ -28,9 +28,9 @@ coreutils --coreutils-prog=yes | head -n10 | uniq > out ||
framework_failure_
compare exp out || fail=1
# A dispatcher name, including a prefixed one, takes a program operand.
-ln -s blah gcoreutils || framework_failure_
+ln -s blah "gcoreutils$EXEEXT" || framework_failure_
echo 'two words ls' > exp || framework_failure_
-for cu in coreutils ./gcoreutils; do
+for cu in coreutils "./gcoreutils$EXEEXT"; do
$cu yes 'two words' ls | head -n1 > out
compare exp out || fail=1
done
--
2.56.0