Hi!

Please consider the attached patch. It prevents 'uname -a' from printing
the same information twice on systems where `uname -s` matches `uname -o`.

2004-07-19  Robert Millan  <[EMAIL PROTECTED]>

        * src/uname.c: When -a is used, only print operating system name if
        different from kernel name.

TIA,

-- 
Robert Millan

"[..] but the delight and pride of Aule is in the deed of making, and in the
thing made, and neither in possession nor in his own mastery; wherefore he
gives and hoards not, and is free from care, passing ever on to some new work."

 -- J.R.R.T., Ainulindale (Silmarillion)
2004-07-19  Robert Millan  <[EMAIL PROTECTED]>

        * src/uname.c: When -a is used, only print operating system name if
        different from kernel name.

--- coreutils-5.2.1/src/uname.c.old     2004-07-19 02:59:58.000000000 +0200
+++ coreutils-5.2.1/src/uname.c 2004-07-19 03:31:19.000000000 +0200
@@ -146,6 +146,7 @@
 {
   int c;
   static char const unknown[] = "unknown";
+  struct utsname name;
 
   /* Mask indicating which elements to print. */
   unsigned toprint = 0;
@@ -221,10 +222,8 @@
 
   if (toprint
        & (PRINT_KERNEL_NAME | PRINT_NODENAME | PRINT_KERNEL_RELEASE
-         | PRINT_KERNEL_VERSION | PRINT_MACHINE))
+         | PRINT_KERNEL_VERSION | PRINT_MACHINE | PRINT_OPERATING_SYSTEM))
     {
-      struct utsname name;
-
       if (uname (&name) == -1)
        error (EXIT_FAILURE, errno, _("cannot get system name"));
 
@@ -287,8 +286,10 @@
       print_element (element);
     }
 
-  if (toprint & PRINT_OPERATING_SYSTEM)
-    print_element (HOST_OPERATING_SYSTEM);
+  /* If -a was chosen, only print OS if different from kernel name. */
+  if ((toprint & PRINT_OPERATING_SYSTEM) &&
+    ((toprint != -1) || strcmp (name.sysname, HOST_OPERATING_SYSTEM)))
+      print_element (HOST_OPERATING_SYSTEM);
 
   putchar ('\n');
 
_______________________________________________
Bug-coreutils mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to