I noticed a discrepancy in the program name output by error(),
which looks to be due to whether the gnulib or glibc version is used.
If we use gnulib's error() it uses getprogname()
which defaults to program_invocation_short_name.
The glibc error() instead uses program_invocation_name.
I don't know why gnulib differs in that regard, and also
I've not looked into why coreutils is using the gnulib error()
given that REPLACE_ERROR=0 and HAVE_ERROR=1,
but in any case program_invocation_name and program_invocation_short_name
should be consistent with each other.
This is not the case because set_program_name()
only sets program_invocation_name normally.
The attached patch also sets program_invocation_short_name
and results in coreutils' tests passing in all cases.
cheers,
Pádraig
From c1dbff3045f4101f91e6d9ee6705d9ed92bea908 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Sun, 12 Jan 2025 16:47:57 +0000
Subject: [PATCH] progname: also set program_invocation_short_name
* lib/progname.c (set_program_name): Keep program_invocation_name
and program_invocation_short_name consistent.
---
ChangeLog | 6 ++++++
lib/progname.c | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 6ccd999e80..b52a2799b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-01-12 Pádraig Brady <p...@draigbrady.com>
+
+ progname: also set program_invocation_short_name
+ * lib/progname.c (set_program_name): Keep program_invocation_name
+ and program_invocation_short_name consistent.
+
2025-01-11 Pádraig Brady <p...@draigbrady.com>
file-has-acl: handle NFSv4 ACLs with listxattr returning EACCES
diff --git a/lib/progname.c b/lib/progname.c
index ee62489285..b6f59f5bb2 100644
--- a/lib/progname.c
+++ b/lib/progname.c
@@ -71,6 +71,10 @@ set_program_name (const char *argv0)
#endif
}
}
+#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+ else
+ program_invocation_short_name = (char *) base;
+#endif
/* But don't strip off a leading <dirname>/ in general, because when the user
runs
--
2.47.1