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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ls/ls.c
          +++ new/usr/src/cmd/ls/ls.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright (c) 2012, Joyent, Inc. All rights reserved.
       25 + * Copyright 2015 Gary Mills
  25   26   */
  26   27  
  27   28  /*
  28   29   * Copyright 2009 Jason King.  All rights reserved.
  29   30   * Use is subject to license terms.
  30   31   */
  31   32  
  32   33  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  33   34  /*        All Rights Reserved   */
  34   35  
↓ open down ↓ 1218 lines elided ↑ open up ↑
1253 1254  static void
1254 1255  pentry(struct lbuf *ap)
1255 1256  {
1256 1257          struct lbuf *p;
1257 1258          numbuf_t hbuf;
1258 1259          char *dmark = "";       /* Used if -p or -F option active */
1259 1260          char *cp;
1260 1261          char *str;
1261 1262  
1262 1263          if (noflist) {
1263      -                (void) printf("%s\n", ap->ln.lname);
     1264 +                (void) printf("%s\n", (ap->lflags & ISARG) ? ap->ln.namep :
     1265 +                    ap->ln.lname);
1264 1266                  return;
1265 1267          }
1266 1268  
1267 1269          p = ap;
1268 1270          column();
1269 1271          if (iflg) {
1270 1272                  if (mflg && !lflg)
1271 1273                          curcol += printf("%llu ", (long long)p->lnum);
1272 1274                  else
1273 1275                          curcol += printf("%10llu ", (long long)p->lnum);
↓ open down ↓ 530 lines elided ↑ open up ↑
1804 1806           * that already has one assigned.
1805 1807           */
1806 1808          if (nfiles >= maxn) {
1807 1809                  rep = nxtlbf++;
1808 1810                  flist[nfiles++] = rep;
1809 1811                  maxn = nfiles;
1810 1812          } else {
1811 1813                  rep = flist[nfiles++];
1812 1814          }
1813 1815  
     1816 +        /* Clear the lbuf */
     1817 +        (void) memset((void *) rep, 0, sizeof (struct lbuf));
     1818 +
1814 1819          /*
1815 1820           * When noflist is set, none of the extra information about the dirent
1816      -         * will be printed, so omit initialization of this lbuf as well as the
1817      -         * stat(2) call.
     1821 +         * will be printed, so omit remaining initialization of this lbuf
     1822 +         * as well as the  stat(2) call.
1818 1823           */
1819 1824          if (!argfl && noflist)
1820 1825                  return (rep);
1821 1826  
1822      -        /* Initialize */
     1827 +        /* Initialize non-zero members */
1823 1828  
1824      -        rep->lflags = (mode_t)0;
1825      -        rep->flinkto = NULL;
1826      -        rep->cycle = 0;
1827 1829          rep->lat.tv_sec = time(NULL);
1828      -        rep->lat.tv_nsec = 0;
1829 1830          rep->lct.tv_sec = time(NULL);
1830      -        rep->lct.tv_nsec = 0;
1831 1831          rep->lmt.tv_sec = time(NULL);
1832      -        rep->lmt.tv_nsec = 0;
1833      -        rep->aclp = NULL;
1834      -        rep->exttr = NULL;
1835      -        rep->extm = NULL;
1836      -        rep->color = NULL;
1837      -        rep->link_color = NULL;
1838 1832  
1839 1833          if (argfl || statreq) {
1840 1834                  int doacl;
1841 1835  
1842 1836                  if (lflg)
1843 1837                          doacl = 1;
1844 1838                  else
1845 1839                          doacl = 0;
1846 1840  
1847 1841                  if ((*statf)(file, &statb) < 0) {
↓ open down ↓ 1366 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX