Print this page
5613 odd ls -U behaviour if output is not a terminal

@@ -20,10 +20,11 @@
  */
 
 /*
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2015 Gary Mills
  */
 
 /*
  * Copyright 2009 Jason King.  All rights reserved.
  * Use is subject to license terms.

@@ -1258,11 +1259,12 @@
         char *dmark = "";       /* Used if -p or -F option active */
         char *cp;
         char *str;
 
         if (noflist) {
-                (void) printf("%s\n", ap->ln.lname);
+                (void) printf("%s\n", (ap->lflags & ISARG) ? ap->ln.namep :
+                    ap->ln.lname);
                 return;
         }
 
         p = ap;
         column();

@@ -1809,34 +1811,26 @@
                 maxn = nfiles;
         } else {
                 rep = flist[nfiles++];
         }
 
+        /* Clear the lbuf */
+        (void) memset((void *) rep, 0, sizeof (struct lbuf));
+
         /*
          * When noflist is set, none of the extra information about the dirent
-         * will be printed, so omit initialization of this lbuf as well as the
-         * stat(2) call.
+         * will be printed, so omit remaining initialization of this lbuf
+         * as well as the  stat(2) call.
          */
         if (!argfl && noflist)
                 return (rep);
 
-        /* Initialize */
+        /* Initialize non-zero members */
 
-        rep->lflags = (mode_t)0;
-        rep->flinkto = NULL;
-        rep->cycle = 0;
         rep->lat.tv_sec = time(NULL);
-        rep->lat.tv_nsec = 0;
         rep->lct.tv_sec = time(NULL);
-        rep->lct.tv_nsec = 0;
         rep->lmt.tv_sec = time(NULL);
-        rep->lmt.tv_nsec = 0;
-        rep->aclp = NULL;
-        rep->exttr = NULL;
-        rep->extm = NULL;
-        rep->color = NULL;
-        rep->link_color = NULL;
 
         if (argfl || statreq) {
                 int doacl;
 
                 if (lflg)