Project Info Name.......: gnu-hello
Description: GNU Hello


gnu-hello       
Info
Commit...:30d4b742eadd600f18b3d26ec1b24dc420812805
Author...:Sami Kerola
Committer:Sami Kerola
Date.....:Sun Jan 20 19:41:05 2019 +0000
Parents..:fabd0112832d978978033866ca92a7deea962c5c

Message
maint: use 'Try --help' statements at failure

* src/system.h: copy define from coreutils.
* src/hello.c: use emit_try_help().

Changes
diff --git a/src/hello.c b/src/hello.c
line changes: +4/-2
index e0699f1..80a3213
--- a/src/hello.c
+++ b/src/hello.c
@@ -101,8 +101,10 @@ main (int argc, char *argv[])
   if (lose || optind < argc)
     {
       /* Print error message and exit.  */
-      error (0, 0, "%s: %s", _("extra operand"), argv[optind]);
-      print_help (stderr);
+      if (argv[optind])
+        error (0, 0, "%s: %s", _("extra operand"), argv[optind]);
+      emit_try_help ();
+      exit (EXIT_FAILURE);
     }
 
   len = mbsrtowcs(NULL, &greeting_msg, 0, NULL);

diff --git a/src/system.h b/src/system.h
line changes: +12/-0
index bdc3811..d39cdb9
--- a/src/system.h
+++ b/src/system.h
@@ -47,4 +47,16 @@
 #define STRNCMP_LIT(s, literal) \
   strncmp (s, "" literal "", sizeof (literal) - 1)
 
+/* Use a macro rather than an inline function, as this references
+   the global program_name, which causes dynamic linking issues
+   in libstdbuf.so on some systems where unused functions
+   are not removed by the linker.  */
+#define emit_try_help() \
+  do \
+    { \
+      fprintf (stderr, _("Try '%s --help' for more information.\n"), \
+               program_name); \
+    } \
+  while (0)
+
 #endif /* HELLO_SYSTEM_H */

This website is licensed under AGPL-3.0. Feel free to copy!