History log of /netbsd-current/bin/ls/ls.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.78 02-Feb-2024 christos

PR/57892: Roberto Branco: Print full pathname in error messages


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.77 07-Jul-2020 christos

Fix skipping of directories that begin with a '.' in -R mode.
It is not enough to avoid displaying the contents of the directory,
we need to set FTS_SKIP to avoid descending into any subdirs too.
Otherwise, if a ".foo" directory has a subdirectory "bar", ls will
descend into bar and display its contents. From Todd Miller


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.76 06-Feb-2017 rin

branches: 1.76.12;
white space


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.75 30-May-2016 dholland

branches: 1.75.2; 1.75.4;
PR 50997 David Binderman: fix format strings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.74 02-Apr-2014 wiz

Apply diff from Igor Sobrado <isd@orion.ciencias.uniovi.es>:

We have written a diff to our ls(1) to recover the traditional behaviour
of -f implying -a. This change does not only accommodates POSIX.1
but also matches traditional UNIX.

OpenBSD commit message:

CVSROOT: /cvs
Module name: src
Changes by: sobrado@cvs.openbsd.org 2014/03/31 14:54:37

Modified files:
bin/ls : ls.1 ls.c

Log message:
restore the traditional behavior of -f implying -a; apparently Keith Bostic
forgot to restore it when the -f flag was put back on 2nd of September 1989,
after being removed on 16th of August as a consequence of issues getting it
working over NFS, so deviation from traditional UNIX behavior in all BSDs
looks like an historical accident; as a side effect, this change accommodates
behavior of this option to IEEE Std 1003.1-2008 (``POSIX.1'').

joint work with jmc@ (who found the inaccuracy in our implementation),
schwarze@ (who provided a detailed tracking of historical facts) and millert@

ok millert@, schwarze@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.73 22-Feb-2014 mlelstv

add u option to getopt again.


# 1.72 21-Feb-2014 christos

Add -X (don't cross mount points when recursing) from tls@


# 1.71 20-Feb-2014 christos

Add -O (only leaf files) and -P (print full path), from tls@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.70 20-Nov-2012 abs

PR/47167
ls.1:
- Sort options in `SYNOPSIS', the option list, and texts within
the man page;
- improve wording;
- improve macro usage;
- use more consistency regarding (locations for) information about
which options override which;
- cross-reference `-d' and `-R';
- simplify description of `-k', removing redundant and unneeded
information;
- sort entry type list (but leave `-a' and `-A' as they are, given
their meaning);
- correct / augment description of `BLOCKSIZE' environment variable
in `ENVIRONMENT' section;
- bump date.

ls.c:
- Sort options in `usage';
- augment comment about when to figure out block size.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.69 29-Aug-2011 joerg

branches: 1.69.2; 1.69.8;
Move usage and mark it static+dead


Revision tags: cherry-xenmp-base
# 1.68 15-Mar-2011 erh

PR#7540, add a -M option to ls which causes sizes (and number of blocks) to be
displayed with comma separators (or a locale specific separator).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.67 08-Jul-2010 rmind

Add #include <sys/param.h> for howmany().


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.66 14-Feb-2009 lukem

fix -Wsign-compare issues


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.65 25-Sep-2008 lukem

branches: 1.65.6;
Change '-n' so that it implies '-l' rather than requires '-l'.
Brings ls(1) closer to POSIX.1 2004.
Per discussion with Thomas Klausner and Igor Sobrado.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.64 20-Jul-2008 lukem

Remove the \n and tabs from the __COPYRIGHT() strings.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.63 14-Dec-2006 he

branches: 1.63.12;
Complete the move of string_to_flags() and flags_to_string() from the
bin/ls sources to libutil:
o Bump libutil minor version number
o Fix uses to include <util.h> to pick up the function definitions
o Fix most uses of flags_to_string() to release the now-malloc()ed result


# 1.62 14-Dec-2006 christos

Pass lint. From Anon Ymous


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.61 23-Sep-2006 elad

PR/34499: mac at S dot culver dot net: ls allocates more memory than needed
Applied patch, thanks!


# 1.60 21-Aug-2006 christos

from zafer: you can have either -k or -h but not both since it does not make
sense.


Revision tags: abandoned-netbsd-4-base
# 1.59 22-Mar-2006 christos

branches: 1.59.2;
Coverity CID 1755: Add fts_close() in traverse.


# 1.58 26-Oct-2005 jschauma

Rather than '-h' suppressing '-s' when using '-l', make it display
the blocks used in human readable form, as suggested by Alan Barrett
and Daniel Carosone.


# 1.57 14-Oct-2005 jschauma

Honor the COLUMNS variable even when producing output not to a terminal,
as long as a specific format (that could use COLUMNS) was requested.
This makes

env COLUMNS=50 ls -C > file

not surprise the user who clearly wanted some specific output in the file.


# 1.56 17-Jun-2005 hira

- Add -h to usage.
- Use set/getprogname(3).


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.55 26-Dec-2003 simonb

Fix bug with previous change- always initialise d.s_block. Now "ls -1sh"
works.
XXX: ls -sh now always uses 4 chars for the size column width even if it
needs less than that.


# 1.54 26-Dec-2003 simonb

KNF - wrap long lines.


# 1.53 26-Dec-2003 grant

implement -h(umanize).

from David P. Reese Jr. in PR bin/23870.


# 1.52 22-Sep-2003 jschauma

After last weeks addition of the '-b' flag, add '-B' and '-w' flags,
suggested by uwe@, inspired by FreeBSD. The three flags override
each other (and the '-q' flag) and behave as follows:

-B Force printing of non-printable characters in file names as
\xxx, where xxx is the numeric value of the character in octal.

-b As -B, but use C escape codes whenever possible.

-w Force raw printing of non-printable characters. This is the
default when output is not to a terminal.


# 1.51 14-Sep-2003 jschauma

Implement '-b' option, which, following FreeBSD, Linux and (I think) Solaris
prints octal escapes for nongraphic characters.


# 1.50 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.


# 1.49 30-May-2003 simonb

Pass a NULL to getbsize() for any arguments that aren't needed, and
remove the otherwise unused variables.


# 1.48 11-May-2003 kleink

If both -g and -l options are present, let -l take precedence over -g,
as requested by several users.

POSIX-2001 is unclear on conflicting option letters as far as the -g
option is concerned; a clarification request will be made.

Addresses PR bin/21519 by Geoff Wing.


# 1.47 07-May-2003 simonb

Add a FALLTHROUGH to keep lint happy.


# 1.46 07-May-2003 grant

make -g behave as it should according to SUSv3 (long listing without
owner).

ok'd by kleink@.


Revision tags: fvdl_fs64_base
# 1.45 27-Sep-2002 simonb

Need to initialise the blocksize variable if the -i option is used
too. The code in display() could possibly be a bit smarter about this
requirement...

Fixes the problem in PR bin/18321 from David Laight and PR bin/18436
from FUKAUMI Naoki.


# 1.44 14-Sep-2002 sommerfeld

Use the output blocksize when computing how much room to leave for the
-s option, to suppress unnecessary leading spaces.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.43 29-Jul-2000 lukem

convert to new KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.42 17-Jun-2000 assar

Do not modify the file name when not printing non-printables, also do
it consistently with the file name and possible symbolic link target.

fixes bin/10385 and bin/10384


Revision tags: minoura-xpg4dl-base
# 1.41 06-Mar-2000 enami

branches: 1.41.2;
- Fix a typo that when group_from_gid is failed (though it merely fails
on NetBSD), numeric gid string is used as `user'.
- Don't mix use %u and %d for numeric uid/gid.
- Share temporary buffer.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.40 09-Nov-1999 drochner

Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.


Revision tags: comdex-fall-1999-base
# 1.39 02-Nov-1999 tron

Call setlocale(3) to use localization in "ls" as suggested by
Jens A Nilsson in PR bin/8730.


# 1.38 17-May-1999 lukem

branches: 1.38.2;
Rename ls.c::main() -> ls.c::ls_main(), and add a wrapper in main.c::main().
This allows other programs to link in against ls (e.g, ftpd), without having
to have hacks to deal with multiple main()s.

Yes, I know this is ugly. The clean alternative (move lots of this
into libutil, yada yada yada) isn't fun, and the effort probably isn't
justified...


# 1.37 04-May-1999 simonb

If an error is encountered, exit with non-zero status.

Based on FreeBSD fix (in 1996!), and fixes PR bin/7514 from
Jorgen Pehrson.


Revision tags: netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.36 17-Feb-1999 kleink

branches: 1.36.2;
Add support for the XCU5 -p option (-F restricted to directories).


# 1.35 12-Feb-1999 kleink

Implement 1003.2 -m option (stream output format).


# 1.34 04-Nov-1998 christos

%q -> %ll


# 1.33 04-Nov-1998 christos

include termios.h for struct winsize


# 1.32 13-Oct-1998 wsanchez

Check for NULL value returned by user_from_uid and group_from_gid and DTRT,
rather than crash.


# 1.31 19-Aug-1998 thorpej

Add some braces to make egcs happy.


# 1.30 28-Jul-1998 mycroft

Delint.


# 1.29 28-Jul-1998 mycroft

Delint.


# 1.28 27-Jul-1998 mycroft

Slight code reduction.


# 1.27 27-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.26 16-May-1998 lukem

* blocks can be 64bit (not u_long), so calculate and display accordingly
* cleanup some other typedamage (int is as good as u_long)
* remove unused variables


# 1.25 03-Feb-1998 mycroft

Deal with GCC warning.


# 1.24 18-Jan-1998 lukem

* implement -x; sort columns across the page rather than down the page
* in printcol(), don't bother building an index to the linked list if
only printing one column with printscol()...
* implement -n; prevent [gu]id->name mapping in long listings.
inspired by openbsd, but does *not* imply -l by itself.
* fix sorting with -d (or mismatched types in general). (from openbsd).
* document -g. (from openbsd).


# 1.23 17-Jan-1998 mycroft

Automatically resize the major and minor number fields, and DTRT if the size
field is not the same size.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.22 30-Jul-1997 thorpej

branches: 1.22.2;
Add some casts to printf args to keep the compiler happy on the Alpha.


# 1.21 20-Jul-1997 christos

include <pwd.h> and <grp.h> to bring prototypes into scope.


# 1.20 20-Jul-1997 christos

remove user_from_uid and group_from_gid prototypes.


# 1.19 20-Jul-1997 christos

Fix compiler warnings.
Add WARNS=1


# 1.18 09-Jul-1996 mycroft

Sort FTS_NS entries by name, just so the order is well-defined.


# 1.17 08-Jul-1996 mycroft

Partition FTS_NS entries from others, to avoid confusing qsort().
Don't bother to order the FTS_NS entries amongst themselves.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 14-Feb-1996 jtc

branches: 1.16.4;
Changed so that COLUMNS environment variable will override the value
obtained via the TIOCGWINSIZ ioctl. This is required by POSIX.2, see
section 4.39.5.3.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 07-Sep-1995 jtc

Sync with 4.4lite2


# 1.14 21-Mar-1995 cgd

convert to new RCS id conventions.


# 1.13 27-Dec-1994 mycroft

Sync with CSRG.


# 1.12 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.11 08-Apr-1994 jtc

Changed traverse() and display() so that errors are reported when
they are first detected in display(), rather than waiting until later
in traverse().

The old code allowed "Can not read directory" error messages to be
left unreported unless the -R (recurse) option was used.


# 1.10 04-Apr-1994 chopps

"yet" on quad_t/off_t things. (not noticed on i386 becuase of endian I guess.)


# 1.9 25-Jan-1994 cgd

(1) fixup getbsize() calls
(2) convert to use err(), warn(), and warnx(), as appropriate.


# 1.8 05-Dec-1993 mycroft

Patches from Thomas Eberhardt <thomas@mathematik.uni-Bremen.de> to allow
sorting by size.


# 1.7 07-Aug-1993 mycroft

New version from uunet, with -k option readded, and 4.4 ffs--specific stuff
in `#ifdef notyet'.


# 1.6 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 26-May-1993 deraadt

previous patch to ls.c wasn't quite correct. This patch from same author.


# 1.4 24-May-1993 deraadt

first environment variable was trounced in the case of
"ls -l". Patch from <bob@obiwan.uucp> Bob Willcox


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.77 07-Jul-2020 christos

Fix skipping of directories that begin with a '.' in -R mode.
It is not enough to avoid displaying the contents of the directory,
we need to set FTS_SKIP to avoid descending into any subdirs too.
Otherwise, if a ".foo" directory has a subdirectory "bar", ls will
descend into bar and display its contents. From Todd Miller


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.76 06-Feb-2017 rin

branches: 1.76.12;
white space


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.75 30-May-2016 dholland

branches: 1.75.2; 1.75.4;
PR 50997 David Binderman: fix format strings


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.74 02-Apr-2014 wiz

Apply diff from Igor Sobrado <isd@orion.ciencias.uniovi.es>:

We have written a diff to our ls(1) to recover the traditional behaviour
of -f implying -a. This change does not only accommodates POSIX.1
but also matches traditional UNIX.

OpenBSD commit message:

CVSROOT: /cvs
Module name: src
Changes by: sobrado@cvs.openbsd.org 2014/03/31 14:54:37

Modified files:
bin/ls : ls.1 ls.c

Log message:
restore the traditional behavior of -f implying -a; apparently Keith Bostic
forgot to restore it when the -f flag was put back on 2nd of September 1989,
after being removed on 16th of August as a consequence of issues getting it
working over NFS, so deviation from traditional UNIX behavior in all BSDs
looks like an historical accident; as a side effect, this change accommodates
behavior of this option to IEEE Std 1003.1-2008 (``POSIX.1'').

joint work with jmc@ (who found the inaccuracy in our implementation),
schwarze@ (who provided a detailed tracking of historical facts) and millert@

ok millert@, schwarze@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.73 22-Feb-2014 mlelstv

add u option to getopt again.


# 1.72 21-Feb-2014 christos

Add -X (don't cross mount points when recursing) from tls@


# 1.71 20-Feb-2014 christos

Add -O (only leaf files) and -P (print full path), from tls@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.70 20-Nov-2012 abs

PR/47167
ls.1:
- Sort options in `SYNOPSIS', the option list, and texts within
the man page;
- improve wording;
- improve macro usage;
- use more consistency regarding (locations for) information about
which options override which;
- cross-reference `-d' and `-R';
- simplify description of `-k', removing redundant and unneeded
information;
- sort entry type list (but leave `-a' and `-A' as they are, given
their meaning);
- correct / augment description of `BLOCKSIZE' environment variable
in `ENVIRONMENT' section;
- bump date.

ls.c:
- Sort options in `usage';
- augment comment about when to figure out block size.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.69 29-Aug-2011 joerg

branches: 1.69.2; 1.69.8;
Move usage and mark it static+dead


Revision tags: cherry-xenmp-base
# 1.68 15-Mar-2011 erh

PR#7540, add a -M option to ls which causes sizes (and number of blocks) to be
displayed with comma separators (or a locale specific separator).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.67 08-Jul-2010 rmind

Add #include <sys/param.h> for howmany().


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.66 14-Feb-2009 lukem

fix -Wsign-compare issues


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.65 25-Sep-2008 lukem

branches: 1.65.6;
Change '-n' so that it implies '-l' rather than requires '-l'.
Brings ls(1) closer to POSIX.1 2004.
Per discussion with Thomas Klausner and Igor Sobrado.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.64 20-Jul-2008 lukem

Remove the \n and tabs from the __COPYRIGHT() strings.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.63 14-Dec-2006 he

branches: 1.63.12;
Complete the move of string_to_flags() and flags_to_string() from the
bin/ls sources to libutil:
o Bump libutil minor version number
o Fix uses to include <util.h> to pick up the function definitions
o Fix most uses of flags_to_string() to release the now-malloc()ed result


# 1.62 14-Dec-2006 christos

Pass lint. From Anon Ymous


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.61 23-Sep-2006 elad

PR/34499: mac at S dot culver dot net: ls allocates more memory than needed
Applied patch, thanks!


# 1.60 21-Aug-2006 christos

from zafer: you can have either -k or -h but not both since it does not make
sense.


Revision tags: abandoned-netbsd-4-base
# 1.59 22-Mar-2006 christos

branches: 1.59.2;
Coverity CID 1755: Add fts_close() in traverse.


# 1.58 26-Oct-2005 jschauma

Rather than '-h' suppressing '-s' when using '-l', make it display
the blocks used in human readable form, as suggested by Alan Barrett
and Daniel Carosone.


# 1.57 14-Oct-2005 jschauma

Honor the COLUMNS variable even when producing output not to a terminal,
as long as a specific format (that could use COLUMNS) was requested.
This makes

env COLUMNS=50 ls -C > file

not surprise the user who clearly wanted some specific output in the file.


# 1.56 17-Jun-2005 hira

- Add -h to usage.
- Use set/getprogname(3).


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.55 26-Dec-2003 simonb

Fix bug with previous change- always initialise d.s_block. Now "ls -1sh"
works.
XXX: ls -sh now always uses 4 chars for the size column width even if it
needs less than that.


# 1.54 26-Dec-2003 simonb

KNF - wrap long lines.


# 1.53 26-Dec-2003 grant

implement -h(umanize).

from David P. Reese Jr. in PR bin/23870.


# 1.52 22-Sep-2003 jschauma

After last weeks addition of the '-b' flag, add '-B' and '-w' flags,
suggested by uwe@, inspired by FreeBSD. The three flags override
each other (and the '-q' flag) and behave as follows:

-B Force printing of non-printable characters in file names as
\xxx, where xxx is the numeric value of the character in octal.

-b As -B, but use C escape codes whenever possible.

-w Force raw printing of non-printable characters. This is the
default when output is not to a terminal.


# 1.51 14-Sep-2003 jschauma

Implement '-b' option, which, following FreeBSD, Linux and (I think) Solaris
prints octal escapes for nongraphic characters.


# 1.50 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.


# 1.49 30-May-2003 simonb

Pass a NULL to getbsize() for any arguments that aren't needed, and
remove the otherwise unused variables.


# 1.48 11-May-2003 kleink

If both -g and -l options are present, let -l take precedence over -g,
as requested by several users.

POSIX-2001 is unclear on conflicting option letters as far as the -g
option is concerned; a clarification request will be made.

Addresses PR bin/21519 by Geoff Wing.


# 1.47 07-May-2003 simonb

Add a FALLTHROUGH to keep lint happy.


# 1.46 07-May-2003 grant

make -g behave as it should according to SUSv3 (long listing without
owner).

ok'd by kleink@.


Revision tags: fvdl_fs64_base
# 1.45 27-Sep-2002 simonb

Need to initialise the blocksize variable if the -i option is used
too. The code in display() could possibly be a bit smarter about this
requirement...

Fixes the problem in PR bin/18321 from David Laight and PR bin/18436
from FUKAUMI Naoki.


# 1.44 14-Sep-2002 sommerfeld

Use the output blocksize when computing how much room to leave for the
-s option, to suppress unnecessary leading spaces.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.43 29-Jul-2000 lukem

convert to new KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.42 17-Jun-2000 assar

Do not modify the file name when not printing non-printables, also do
it consistently with the file name and possible symbolic link target.

fixes bin/10385 and bin/10384


Revision tags: minoura-xpg4dl-base
# 1.41 06-Mar-2000 enami

branches: 1.41.2;
- Fix a typo that when group_from_gid is failed (though it merely fails
on NetBSD), numeric gid string is used as `user'.
- Don't mix use %u and %d for numeric uid/gid.
- Share temporary buffer.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.40 09-Nov-1999 drochner

Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.


Revision tags: comdex-fall-1999-base
# 1.39 02-Nov-1999 tron

Call setlocale(3) to use localization in "ls" as suggested by
Jens A Nilsson in PR bin/8730.


# 1.38 17-May-1999 lukem

branches: 1.38.2;
Rename ls.c::main() -> ls.c::ls_main(), and add a wrapper in main.c::main().
This allows other programs to link in against ls (e.g, ftpd), without having
to have hacks to deal with multiple main()s.

Yes, I know this is ugly. The clean alternative (move lots of this
into libutil, yada yada yada) isn't fun, and the effort probably isn't
justified...


# 1.37 04-May-1999 simonb

If an error is encountered, exit with non-zero status.

Based on FreeBSD fix (in 1996!), and fixes PR bin/7514 from
Jorgen Pehrson.


Revision tags: netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.36 17-Feb-1999 kleink

branches: 1.36.2;
Add support for the XCU5 -p option (-F restricted to directories).


# 1.35 12-Feb-1999 kleink

Implement 1003.2 -m option (stream output format).


# 1.34 04-Nov-1998 christos

%q -> %ll


# 1.33 04-Nov-1998 christos

include termios.h for struct winsize


# 1.32 13-Oct-1998 wsanchez

Check for NULL value returned by user_from_uid and group_from_gid and DTRT,
rather than crash.


# 1.31 19-Aug-1998 thorpej

Add some braces to make egcs happy.


# 1.30 28-Jul-1998 mycroft

Delint.


# 1.29 28-Jul-1998 mycroft

Delint.


# 1.28 27-Jul-1998 mycroft

Slight code reduction.


# 1.27 27-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.26 16-May-1998 lukem

* blocks can be 64bit (not u_long), so calculate and display accordingly
* cleanup some other typedamage (int is as good as u_long)
* remove unused variables


# 1.25 03-Feb-1998 mycroft

Deal with GCC warning.


# 1.24 18-Jan-1998 lukem

* implement -x; sort columns across the page rather than down the page
* in printcol(), don't bother building an index to the linked list if
only printing one column with printscol()...
* implement -n; prevent [gu]id->name mapping in long listings.
inspired by openbsd, but does *not* imply -l by itself.
* fix sorting with -d (or mismatched types in general). (from openbsd).
* document -g. (from openbsd).


# 1.23 17-Jan-1998 mycroft

Automatically resize the major and minor number fields, and DTRT if the size
field is not the same size.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.22 30-Jul-1997 thorpej

branches: 1.22.2;
Add some casts to printf args to keep the compiler happy on the Alpha.


# 1.21 20-Jul-1997 christos

include <pwd.h> and <grp.h> to bring prototypes into scope.


# 1.20 20-Jul-1997 christos

remove user_from_uid and group_from_gid prototypes.


# 1.19 20-Jul-1997 christos

Fix compiler warnings.
Add WARNS=1


# 1.18 09-Jul-1996 mycroft

Sort FTS_NS entries by name, just so the order is well-defined.


# 1.17 08-Jul-1996 mycroft

Partition FTS_NS entries from others, to avoid confusing qsort().
Don't bother to order the FTS_NS entries amongst themselves.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 14-Feb-1996 jtc

branches: 1.16.4;
Changed so that COLUMNS environment variable will override the value
obtained via the TIOCGWINSIZ ioctl. This is required by POSIX.2, see
section 4.39.5.3.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 07-Sep-1995 jtc

Sync with 4.4lite2


# 1.14 21-Mar-1995 cgd

convert to new RCS id conventions.


# 1.13 27-Dec-1994 mycroft

Sync with CSRG.


# 1.12 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.11 08-Apr-1994 jtc

Changed traverse() and display() so that errors are reported when
they are first detected in display(), rather than waiting until later
in traverse().

The old code allowed "Can not read directory" error messages to be
left unreported unless the -R (recurse) option was used.


# 1.10 04-Apr-1994 chopps

"yet" on quad_t/off_t things. (not noticed on i386 becuase of endian I guess.)


# 1.9 25-Jan-1994 cgd

(1) fixup getbsize() calls
(2) convert to use err(), warn(), and warnx(), as appropriate.


# 1.8 05-Dec-1993 mycroft

Patches from Thomas Eberhardt <thomas@mathematik.uni-Bremen.de> to allow
sorting by size.


# 1.7 07-Aug-1993 mycroft

New version from uunet, with -k option readded, and 4.4 ffs--specific stuff
in `#ifdef notyet'.


# 1.6 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 26-May-1993 deraadt

previous patch to ls.c wasn't quite correct. This patch from same author.


# 1.4 24-May-1993 deraadt

first environment variable was trounced in the case of
"ls -l". Patch from <bob@obiwan.uucp> Bob Willcox


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.76 06-Feb-2017 rin

white space


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.75 30-May-2016 dholland

PR 50997 David Binderman: fix format strings


Revision tags: netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.74 02-Apr-2014 wiz

Apply diff from Igor Sobrado <isd@orion.ciencias.uniovi.es>:

We have written a diff to our ls(1) to recover the traditional behaviour
of -f implying -a. This change does not only accommodates POSIX.1
but also matches traditional UNIX.

OpenBSD commit message:

CVSROOT: /cvs
Module name: src
Changes by: sobrado@cvs.openbsd.org 2014/03/31 14:54:37

Modified files:
bin/ls : ls.1 ls.c

Log message:
restore the traditional behavior of -f implying -a; apparently Keith Bostic
forgot to restore it when the -f flag was put back on 2nd of September 1989,
after being removed on 16th of August as a consequence of issues getting it
working over NFS, so deviation from traditional UNIX behavior in all BSDs
looks like an historical accident; as a side effect, this change accommodates
behavior of this option to IEEE Std 1003.1-2008 (``POSIX.1'').

joint work with jmc@ (who found the inaccuracy in our implementation),
schwarze@ (who provided a detailed tracking of historical facts) and millert@

ok millert@, schwarze@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.73 22-Feb-2014 mlelstv

add u option to getopt again.


# 1.72 21-Feb-2014 christos

Add -X (don't cross mount points when recursing) from tls@


# 1.71 20-Feb-2014 christos

Add -O (only leaf files) and -P (print full path), from tls@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.70 20-Nov-2012 abs

PR/47167
ls.1:
- Sort options in `SYNOPSIS', the option list, and texts within
the man page;
- improve wording;
- improve macro usage;
- use more consistency regarding (locations for) information about
which options override which;
- cross-reference `-d' and `-R';
- simplify description of `-k', removing redundant and unneeded
information;
- sort entry type list (but leave `-a' and `-A' as they are, given
their meaning);
- correct / augment description of `BLOCKSIZE' environment variable
in `ENVIRONMENT' section;
- bump date.

ls.c:
- Sort options in `usage';
- augment comment about when to figure out block size.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.69 29-Aug-2011 joerg

branches: 1.69.2; 1.69.8;
Move usage and mark it static+dead


Revision tags: cherry-xenmp-base
# 1.68 15-Mar-2011 erh

PR#7540, add a -M option to ls which causes sizes (and number of blocks) to be
displayed with comma separators (or a locale specific separator).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.67 08-Jul-2010 rmind

Add #include <sys/param.h> for howmany().


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.66 14-Feb-2009 lukem

fix -Wsign-compare issues


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.65 25-Sep-2008 lukem

branches: 1.65.6;
Change '-n' so that it implies '-l' rather than requires '-l'.
Brings ls(1) closer to POSIX.1 2004.
Per discussion with Thomas Klausner and Igor Sobrado.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.64 20-Jul-2008 lukem

Remove the \n and tabs from the __COPYRIGHT() strings.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.63 14-Dec-2006 he

branches: 1.63.12;
Complete the move of string_to_flags() and flags_to_string() from the
bin/ls sources to libutil:
o Bump libutil minor version number
o Fix uses to include <util.h> to pick up the function definitions
o Fix most uses of flags_to_string() to release the now-malloc()ed result


# 1.62 14-Dec-2006 christos

Pass lint. From Anon Ymous


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.61 23-Sep-2006 elad

PR/34499: mac at S dot culver dot net: ls allocates more memory than needed
Applied patch, thanks!


# 1.60 21-Aug-2006 christos

from zafer: you can have either -k or -h but not both since it does not make
sense.


Revision tags: abandoned-netbsd-4-base
# 1.59 22-Mar-2006 christos

branches: 1.59.2;
Coverity CID 1755: Add fts_close() in traverse.


# 1.58 26-Oct-2005 jschauma

Rather than '-h' suppressing '-s' when using '-l', make it display
the blocks used in human readable form, as suggested by Alan Barrett
and Daniel Carosone.


# 1.57 14-Oct-2005 jschauma

Honor the COLUMNS variable even when producing output not to a terminal,
as long as a specific format (that could use COLUMNS) was requested.
This makes

env COLUMNS=50 ls -C > file

not surprise the user who clearly wanted some specific output in the file.


# 1.56 17-Jun-2005 hira

- Add -h to usage.
- Use set/getprogname(3).


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.55 26-Dec-2003 simonb

Fix bug with previous change- always initialise d.s_block. Now "ls -1sh"
works.
XXX: ls -sh now always uses 4 chars for the size column width even if it
needs less than that.


# 1.54 26-Dec-2003 simonb

KNF - wrap long lines.


# 1.53 26-Dec-2003 grant

implement -h(umanize).

from David P. Reese Jr. in PR bin/23870.


# 1.52 22-Sep-2003 jschauma

After last weeks addition of the '-b' flag, add '-B' and '-w' flags,
suggested by uwe@, inspired by FreeBSD. The three flags override
each other (and the '-q' flag) and behave as follows:

-B Force printing of non-printable characters in file names as
\xxx, where xxx is the numeric value of the character in octal.

-b As -B, but use C escape codes whenever possible.

-w Force raw printing of non-printable characters. This is the
default when output is not to a terminal.


# 1.51 14-Sep-2003 jschauma

Implement '-b' option, which, following FreeBSD, Linux and (I think) Solaris
prints octal escapes for nongraphic characters.


# 1.50 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.


# 1.49 30-May-2003 simonb

Pass a NULL to getbsize() for any arguments that aren't needed, and
remove the otherwise unused variables.


# 1.48 11-May-2003 kleink

If both -g and -l options are present, let -l take precedence over -g,
as requested by several users.

POSIX-2001 is unclear on conflicting option letters as far as the -g
option is concerned; a clarification request will be made.

Addresses PR bin/21519 by Geoff Wing.


# 1.47 07-May-2003 simonb

Add a FALLTHROUGH to keep lint happy.


# 1.46 07-May-2003 grant

make -g behave as it should according to SUSv3 (long listing without
owner).

ok'd by kleink@.


Revision tags: fvdl_fs64_base
# 1.45 27-Sep-2002 simonb

Need to initialise the blocksize variable if the -i option is used
too. The code in display() could possibly be a bit smarter about this
requirement...

Fixes the problem in PR bin/18321 from David Laight and PR bin/18436
from FUKAUMI Naoki.


# 1.44 14-Sep-2002 sommerfeld

Use the output blocksize when computing how much room to leave for the
-s option, to suppress unnecessary leading spaces.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.43 29-Jul-2000 lukem

convert to new KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.42 17-Jun-2000 assar

Do not modify the file name when not printing non-printables, also do
it consistently with the file name and possible symbolic link target.

fixes bin/10385 and bin/10384


Revision tags: minoura-xpg4dl-base
# 1.41 06-Mar-2000 enami

branches: 1.41.2;
- Fix a typo that when group_from_gid is failed (though it merely fails
on NetBSD), numeric gid string is used as `user'.
- Don't mix use %u and %d for numeric uid/gid.
- Share temporary buffer.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.40 09-Nov-1999 drochner

Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.


Revision tags: comdex-fall-1999-base
# 1.39 02-Nov-1999 tron

Call setlocale(3) to use localization in "ls" as suggested by
Jens A Nilsson in PR bin/8730.


# 1.38 17-May-1999 lukem

branches: 1.38.2;
Rename ls.c::main() -> ls.c::ls_main(), and add a wrapper in main.c::main().
This allows other programs to link in against ls (e.g, ftpd), without having
to have hacks to deal with multiple main()s.

Yes, I know this is ugly. The clean alternative (move lots of this
into libutil, yada yada yada) isn't fun, and the effort probably isn't
justified...


# 1.37 04-May-1999 simonb

If an error is encountered, exit with non-zero status.

Based on FreeBSD fix (in 1996!), and fixes PR bin/7514 from
Jorgen Pehrson.


Revision tags: netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.36 17-Feb-1999 kleink

branches: 1.36.2;
Add support for the XCU5 -p option (-F restricted to directories).


# 1.35 12-Feb-1999 kleink

Implement 1003.2 -m option (stream output format).


# 1.34 04-Nov-1998 christos

%q -> %ll


# 1.33 04-Nov-1998 christos

include termios.h for struct winsize


# 1.32 13-Oct-1998 wsanchez

Check for NULL value returned by user_from_uid and group_from_gid and DTRT,
rather than crash.


# 1.31 19-Aug-1998 thorpej

Add some braces to make egcs happy.


# 1.30 28-Jul-1998 mycroft

Delint.


# 1.29 28-Jul-1998 mycroft

Delint.


# 1.28 27-Jul-1998 mycroft

Slight code reduction.


# 1.27 27-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.26 16-May-1998 lukem

* blocks can be 64bit (not u_long), so calculate and display accordingly
* cleanup some other typedamage (int is as good as u_long)
* remove unused variables


# 1.25 03-Feb-1998 mycroft

Deal with GCC warning.


# 1.24 18-Jan-1998 lukem

* implement -x; sort columns across the page rather than down the page
* in printcol(), don't bother building an index to the linked list if
only printing one column with printscol()...
* implement -n; prevent [gu]id->name mapping in long listings.
inspired by openbsd, but does *not* imply -l by itself.
* fix sorting with -d (or mismatched types in general). (from openbsd).
* document -g. (from openbsd).


# 1.23 17-Jan-1998 mycroft

Automatically resize the major and minor number fields, and DTRT if the size
field is not the same size.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.22 30-Jul-1997 thorpej

branches: 1.22.2;
Add some casts to printf args to keep the compiler happy on the Alpha.


# 1.21 20-Jul-1997 christos

include <pwd.h> and <grp.h> to bring prototypes into scope.


# 1.20 20-Jul-1997 christos

remove user_from_uid and group_from_gid prototypes.


# 1.19 20-Jul-1997 christos

Fix compiler warnings.
Add WARNS=1


# 1.18 09-Jul-1996 mycroft

Sort FTS_NS entries by name, just so the order is well-defined.


# 1.17 08-Jul-1996 mycroft

Partition FTS_NS entries from others, to avoid confusing qsort().
Don't bother to order the FTS_NS entries amongst themselves.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 14-Feb-1996 jtc

branches: 1.16.4;
Changed so that COLUMNS environment variable will override the value
obtained via the TIOCGWINSIZ ioctl. This is required by POSIX.2, see
section 4.39.5.3.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 07-Sep-1995 jtc

Sync with 4.4lite2


# 1.14 21-Mar-1995 cgd

convert to new RCS id conventions.


# 1.13 27-Dec-1994 mycroft

Sync with CSRG.


# 1.12 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.11 08-Apr-1994 jtc

Changed traverse() and display() so that errors are reported when
they are first detected in display(), rather than waiting until later
in traverse().

The old code allowed "Can not read directory" error messages to be
left unreported unless the -R (recurse) option was used.


# 1.10 04-Apr-1994 chopps

"yet" on quad_t/off_t things. (not noticed on i386 becuase of endian I guess.)


# 1.9 25-Jan-1994 cgd

(1) fixup getbsize() calls
(2) convert to use err(), warn(), and warnx(), as appropriate.


# 1.8 05-Dec-1993 mycroft

Patches from Thomas Eberhardt <thomas@mathematik.uni-Bremen.de> to allow
sorting by size.


# 1.7 07-Aug-1993 mycroft

New version from uunet, with -k option readded, and 4.4 ffs--specific stuff
in `#ifdef notyet'.


# 1.6 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 26-May-1993 deraadt

previous patch to ls.c wasn't quite correct. This patch from same author.


# 1.4 24-May-1993 deraadt

first environment variable was trounced in the case of
"ls -l". Patch from <bob@obiwan.uucp> Bob Willcox


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.75 30-May-2016 dholland

PR 50997 David Binderman: fix format strings


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.74 02-Apr-2014 wiz

Apply diff from Igor Sobrado <isd@orion.ciencias.uniovi.es>:

We have written a diff to our ls(1) to recover the traditional behaviour
of -f implying -a. This change does not only accommodates POSIX.1
but also matches traditional UNIX.

OpenBSD commit message:

CVSROOT: /cvs
Module name: src
Changes by: sobrado@cvs.openbsd.org 2014/03/31 14:54:37

Modified files:
bin/ls : ls.1 ls.c

Log message:
restore the traditional behavior of -f implying -a; apparently Keith Bostic
forgot to restore it when the -f flag was put back on 2nd of September 1989,
after being removed on 16th of August as a consequence of issues getting it
working over NFS, so deviation from traditional UNIX behavior in all BSDs
looks like an historical accident; as a side effect, this change accommodates
behavior of this option to IEEE Std 1003.1-2008 (``POSIX.1'').

joint work with jmc@ (who found the inaccuracy in our implementation),
schwarze@ (who provided a detailed tracking of historical facts) and millert@

ok millert@, schwarze@


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.73 22-Feb-2014 mlelstv

add u option to getopt again.


# 1.72 20-Feb-2014 christos

Add -X (don't cross mount points when recursing) from tls@


# 1.71 20-Feb-2014 christos

Add -O (only leaf files) and -P (print full path), from tls@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.70 19-Nov-2012 abs

PR/47167
ls.1:
- Sort options in `SYNOPSIS', the option list, and texts within
the man page;
- improve wording;
- improve macro usage;
- use more consistency regarding (locations for) information about
which options override which;
- cross-reference `-d' and `-R';
- simplify description of `-k', removing redundant and unneeded
information;
- sort entry type list (but leave `-a' and `-A' as they are, given
their meaning);
- correct / augment description of `BLOCKSIZE' environment variable
in `ENVIRONMENT' section;
- bump date.

ls.c:
- Sort options in `usage';
- augment comment about when to figure out block size.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.69 29-Aug-2011 joerg

branches: 1.69.2; 1.69.8;
Move usage and mark it static+dead


Revision tags: cherry-xenmp-base
# 1.68 14-Mar-2011 erh

PR#7540, add a -M option to ls which causes sizes (and number of blocks) to be
displayed with comma separators (or a locale specific separator).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.67 08-Jul-2010 rmind

Add #include <sys/param.h> for howmany().


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.66 14-Feb-2009 lukem

fix -Wsign-compare issues


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.65 25-Sep-2008 lukem

branches: 1.65.6;
Change '-n' so that it implies '-l' rather than requires '-l'.
Brings ls(1) closer to POSIX.1 2004.
Per discussion with Thomas Klausner and Igor Sobrado.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.64 19-Jul-2008 lukem

Remove the \n and tabs from the __COPYRIGHT() strings.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.63 14-Dec-2006 he

branches: 1.63.12;
Complete the move of string_to_flags() and flags_to_string() from the
bin/ls sources to libutil:
o Bump libutil minor version number
o Fix uses to include <util.h> to pick up the function definitions
o Fix most uses of flags_to_string() to release the now-malloc()ed result


# 1.62 14-Dec-2006 christos

Pass lint. From Anon Ymous


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.61 23-Sep-2006 elad

PR/34499: mac at S dot culver dot net: ls allocates more memory than needed
Applied patch, thanks!


# 1.60 21-Aug-2006 christos

from zafer: you can have either -k or -h but not both since it does not make
sense.


Revision tags: abandoned-netbsd-4-base
# 1.59 22-Mar-2006 christos

branches: 1.59.2;
Coverity CID 1755: Add fts_close() in traverse.


# 1.58 25-Oct-2005 jschauma

Rather than '-h' suppressing '-s' when using '-l', make it display
the blocks used in human readable form, as suggested by Alan Barrett
and Daniel Carosone.


# 1.57 14-Oct-2005 jschauma

Honor the COLUMNS variable even when producing output not to a terminal,
as long as a specific format (that could use COLUMNS) was requested.
This makes

env COLUMNS=50 ls -C > file

not surprise the user who clearly wanted some specific output in the file.


# 1.56 17-Jun-2005 hira

- Add -h to usage.
- Use set/getprogname(3).


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.55 26-Dec-2003 simonb

Fix bug with previous change- always initialise d.s_block. Now "ls -1sh"
works.
XXX: ls -sh now always uses 4 chars for the size column width even if it
needs less than that.


# 1.54 26-Dec-2003 simonb

KNF - wrap long lines.


# 1.53 25-Dec-2003 grant

implement -h(umanize).

from David P. Reese Jr. in PR bin/23870.


# 1.52 21-Sep-2003 jschauma

After last weeks addition of the '-b' flag, add '-B' and '-w' flags,
suggested by uwe@, inspired by FreeBSD. The three flags override
each other (and the '-q' flag) and behave as follows:

-B Force printing of non-printable characters in file names as
\xxx, where xxx is the numeric value of the character in octal.

-b As -B, but use C escape codes whenever possible.

-w Force raw printing of non-printable characters. This is the
default when output is not to a terminal.


# 1.51 14-Sep-2003 jschauma

Implement '-b' option, which, following FreeBSD, Linux and (I think) Solaris
prints octal escapes for nongraphic characters.


# 1.50 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.


# 1.49 29-May-2003 simonb

Pass a NULL to getbsize() for any arguments that aren't needed, and
remove the otherwise unused variables.


# 1.48 11-May-2003 kleink

If both -g and -l options are present, let -l take precedence over -g,
as requested by several users.

POSIX-2001 is unclear on conflicting option letters as far as the -g
option is concerned; a clarification request will be made.

Addresses PR bin/21519 by Geoff Wing.


# 1.47 07-May-2003 simonb

Add a FALLTHROUGH to keep lint happy.


# 1.46 07-May-2003 grant

make -g behave as it should according to SUSv3 (long listing without
owner).

ok'd by kleink@.


Revision tags: fvdl_fs64_base
# 1.45 26-Sep-2002 simonb

Need to initialise the blocksize variable if the -i option is used
too. The code in display() could possibly be a bit smarter about this
requirement...

Fixes the problem in PR bin/18321 from David Laight and PR bin/18436
from FUKAUMI Naoki.


# 1.44 13-Sep-2002 sommerfeld

Use the output blocksize when computing how much room to leave for the
-s option, to suppress unnecessary leading spaces.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.43 28-Jul-2000 lukem

convert to new KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.42 17-Jun-2000 assar

Do not modify the file name when not printing non-printables, also do
it consistently with the file name and possible symbolic link target.

fixes bin/10385 and bin/10384


Revision tags: minoura-xpg4dl-base
# 1.41 06-Mar-2000 enami

branches: 1.41.2;
- Fix a typo that when group_from_gid is failed (though it merely fails
on NetBSD), numeric gid string is used as `user'.
- Don't mix use %u and %d for numeric uid/gid.
- Share temporary buffer.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.40 09-Nov-1999 drochner

Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.


Revision tags: comdex-fall-1999-base
# 1.39 02-Nov-1999 tron

Call setlocale(3) to use localization in "ls" as suggested by
Jens A Nilsson in PR bin/8730.


# 1.38 16-May-1999 lukem

branches: 1.38.2;
Rename ls.c::main() -> ls.c::ls_main(), and add a wrapper in main.c::main().
This allows other programs to link in against ls (e.g, ftpd), without having
to have hacks to deal with multiple main()s.

Yes, I know this is ugly. The clean alternative (move lots of this
into libutil, yada yada yada) isn't fun, and the effort probably isn't
justified...


# 1.37 04-May-1999 simonb

If an error is encountered, exit with non-zero status.

Based on FreeBSD fix (in 1996!), and fixes PR bin/7514 from
Jorgen Pehrson.


Revision tags: netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.36 17-Feb-1999 kleink

branches: 1.36.2;
Add support for the XCU5 -p option (-F restricted to directories).


# 1.35 12-Feb-1999 kleink

Implement 1003.2 -m option (stream output format).


# 1.34 04-Nov-1998 christos

%q -> %ll


# 1.33 04-Nov-1998 christos

include termios.h for struct winsize


# 1.32 13-Oct-1998 wsanchez

Check for NULL value returned by user_from_uid and group_from_gid and DTRT,
rather than crash.


# 1.31 18-Aug-1998 thorpej

Add some braces to make egcs happy.


# 1.30 27-Jul-1998 mycroft

Delint.


# 1.29 27-Jul-1998 mycroft

Delint.


# 1.28 27-Jul-1998 mycroft

Slight code reduction.


# 1.27 27-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.26 16-May-1998 lukem

* blocks can be 64bit (not u_long), so calculate and display accordingly
* cleanup some other typedamage (int is as good as u_long)
* remove unused variables


# 1.25 02-Feb-1998 mycroft

Deal with GCC warning.


# 1.24 18-Jan-1998 lukem

* implement -x; sort columns across the page rather than down the page
* in printcol(), don't bother building an index to the linked list if
only printing one column with printscol()...
* implement -n; prevent [gu]id->name mapping in long listings.
inspired by openbsd, but does *not* imply -l by itself.
* fix sorting with -d (or mismatched types in general). (from openbsd).
* document -g. (from openbsd).


# 1.23 16-Jan-1998 mycroft

Automatically resize the major and minor number fields, and DTRT if the size
field is not the same size.


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.22 29-Jul-1997 thorpej

branches: 1.22.2;
Add some casts to printf args to keep the compiler happy on the Alpha.


# 1.21 20-Jul-1997 christos

include <pwd.h> and <grp.h> to bring prototypes into scope.


# 1.20 20-Jul-1997 christos

remove user_from_uid and group_from_gid prototypes.


# 1.19 20-Jul-1997 christos

Fix compiler warnings.
Add WARNS=1


# 1.18 09-Jul-1996 mycroft

Sort FTS_NS entries by name, just so the order is well-defined.


# 1.17 08-Jul-1996 mycroft

Partition FTS_NS entries from others, to avoid confusing qsort().
Don't bother to order the FTS_NS entries amongst themselves.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 13-Feb-1996 jtc

branches: 1.16.4;
Changed so that COLUMNS environment variable will override the value
obtained via the TIOCGWINSIZ ioctl. This is required by POSIX.2, see
section 4.39.5.3.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 07-Sep-1995 jtc

Sync with 4.4lite2


# 1.14 21-Mar-1995 cgd

convert to new RCS id conventions.


# 1.13 27-Dec-1994 mycroft

Sync with CSRG.


# 1.12 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.11 07-Apr-1994 jtc

Changed traverse() and display() so that errors are reported when
they are first detected in display(), rather than waiting until later
in traverse().

The old code allowed "Can not read directory" error messages to be
left unreported unless the -R (recurse) option was used.


# 1.10 04-Apr-1994 chopps

"yet" on quad_t/off_t things. (not noticed on i386 becuase of endian I guess.)


# 1.9 25-Jan-1994 cgd

(1) fixup getbsize() calls
(2) convert to use err(), warn(), and warnx(), as appropriate.


# 1.8 05-Dec-1993 mycroft

Patches from Thomas Eberhardt <thomas@mathematik.uni-Bremen.de> to allow
sorting by size.


# 1.7 06-Aug-1993 mycroft

New version from uunet, with -k option readded, and 4.4 ffs--specific stuff
in `#ifdef notyet'.


# 1.6 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 26-May-1993 deraadt

previous patch to ls.c wasn't quite correct. This patch from same author.


# 1.4 24-May-1993 deraadt

first environment variable was trounced in the case of
"ls -l". Patch from <bob@obiwan.uucp> Bob Willcox


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.3 22-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.74 02-Apr-2014 wiz

Apply diff from Igor Sobrado <isd@orion.ciencias.uniovi.es>:

We have written a diff to our ls(1) to recover the traditional behaviour
of -f implying -a. This change does not only accommodates POSIX.1
but also matches traditional UNIX.

OpenBSD commit message:

CVSROOT: /cvs
Module name: src
Changes by: sobrado@cvs.openbsd.org 2014/03/31 14:54:37

Modified files:
bin/ls : ls.1 ls.c

Log message:
restore the traditional behavior of -f implying -a; apparently Keith Bostic
forgot to restore it when the -f flag was put back on 2nd of September 1989,
after being removed on 16th of August as a consequence of issues getting it
working over NFS, so deviation from traditional UNIX behavior in all BSDs
looks like an historical accident; as a side effect, this change accommodates
behavior of this option to IEEE Std 1003.1-2008 (``POSIX.1'').

joint work with jmc@ (who found the inaccuracy in our implementation),
schwarze@ (who provided a detailed tracking of historical facts) and millert@

ok millert@, schwarze@


# 1.73 22-Feb-2014 mlelstv

add u option to getopt again.


# 1.72 20-Feb-2014 christos

Add -X (don't cross mount points when recursing) from tls@


# 1.71 20-Feb-2014 christos

Add -O (only leaf files) and -P (print full path), from tls@


# 1.70 20-Nov-2012 abs

PR/47167
ls.1:
- Sort options in `SYNOPSIS', the option list, and texts within
the man page;
- improve wording;
- improve macro usage;
- use more consistency regarding (locations for) information about
which options override which;
- cross-reference `-d' and `-R';
- simplify description of `-k', removing redundant and unneeded
information;
- sort entry type list (but leave `-a' and `-A' as they are, given
their meaning);
- correct / augment description of `BLOCKSIZE' environment variable
in `ENVIRONMENT' section;
- bump date.

ls.c:
- Sort options in `usage';
- augment comment about when to figure out block size.


# 1.69 29-Aug-2011 joerg

branches: 1.69.2; 1.69.8;
Move usage and mark it static+dead


# 1.68 14-Mar-2011 erh

PR#7540, add a -M option to ls which causes sizes (and number of blocks) to be
displayed with comma separators (or a locale specific separator).


# 1.67 08-Jul-2010 rmind

Add #include <sys/param.h> for howmany().


# 1.66 14-Feb-2009 lukem

fix -Wsign-compare issues


# 1.65 25-Sep-2008 lukem

branches: 1.65.6;
Change '-n' so that it implies '-l' rather than requires '-l'.
Brings ls(1) closer to POSIX.1 2004.
Per discussion with Thomas Klausner and Igor Sobrado.


# 1.64 19-Jul-2008 lukem

Remove the \n and tabs from the __COPYRIGHT() strings.


# 1.63 14-Dec-2006 he

branches: 1.63.12;
Complete the move of string_to_flags() and flags_to_string() from the
bin/ls sources to libutil:
o Bump libutil minor version number
o Fix uses to include <util.h> to pick up the function definitions
o Fix most uses of flags_to_string() to release the now-malloc()ed result


# 1.62 14-Dec-2006 christos

Pass lint. From Anon Ymous


# 1.61 23-Sep-2006 elad

PR/34499: mac at S dot culver dot net: ls allocates more memory than needed
Applied patch, thanks!


# 1.60 21-Aug-2006 christos

from zafer: you can have either -k or -h but not both since it does not make
sense.


# 1.59 22-Mar-2006 christos

branches: 1.59.2;
Coverity CID 1755: Add fts_close() in traverse.


# 1.58 25-Oct-2005 jschauma

Rather than '-h' suppressing '-s' when using '-l', make it display
the blocks used in human readable form, as suggested by Alan Barrett
and Daniel Carosone.


# 1.57 13-Oct-2005 jschauma

Honor the COLUMNS variable even when producing output not to a terminal,
as long as a specific format (that could use COLUMNS) was requested.
This makes

env COLUMNS=50 ls -C > file

not surprise the user who clearly wanted some specific output in the file.


# 1.56 17-Jun-2005 hira

- Add -h to usage.
- Use set/getprogname(3).


# 1.55 26-Dec-2003 simonb

Fix bug with previous change- always initialise d.s_block. Now "ls -1sh"
works.
XXX: ls -sh now always uses 4 chars for the size column width even if it
needs less than that.


# 1.54 26-Dec-2003 simonb

KNF - wrap long lines.


# 1.53 25-Dec-2003 grant

implement -h(umanize).

from David P. Reese Jr. in PR bin/23870.


# 1.52 21-Sep-2003 jschauma

After last weeks addition of the '-b' flag, add '-B' and '-w' flags,
suggested by uwe@, inspired by FreeBSD. The three flags override
each other (and the '-q' flag) and behave as follows:

-B Force printing of non-printable characters in file names as
\xxx, where xxx is the numeric value of the character in octal.

-b As -B, but use C escape codes whenever possible.

-w Force raw printing of non-printable characters. This is the
default when output is not to a terminal.


# 1.51 14-Sep-2003 jschauma

Implement '-b' option, which, following FreeBSD, Linux and (I think) Solaris
prints octal escapes for nongraphic characters.


# 1.50 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.


# 1.49 29-May-2003 simonb

Pass a NULL to getbsize() for any arguments that aren't needed, and
remove the otherwise unused variables.


# 1.48 11-May-2003 kleink

If both -g and -l options are present, let -l take precedence over -g,
as requested by several users.

POSIX-2001 is unclear on conflicting option letters as far as the -g
option is concerned; a clarification request will be made.

Addresses PR bin/21519 by Geoff Wing.


# 1.47 07-May-2003 simonb

Add a FALLTHROUGH to keep lint happy.


# 1.46 07-May-2003 grant

make -g behave as it should according to SUSv3 (long listing without
owner).

ok'd by kleink@.


# 1.45 27-Sep-2002 simonb

Need to initialise the blocksize variable if the -i option is used
too. The code in display() could possibly be a bit smarter about this
requirement...

Fixes the problem in PR bin/18321 from David Laight and PR bin/18436
from FUKAUMI Naoki.


# 1.44 13-Sep-2002 sommerfeld

Use the output blocksize when computing how much room to leave for the
-s option, to suppress unnecessary leading spaces.


# 1.43 28-Jul-2000 lukem

convert to new KNF


# 1.42 16-Jun-2000 assar

Do not modify the file name when not printing non-printables, also do
it consistently with the file name and possible symbolic link target.

fixes bin/10385 and bin/10384


# 1.41 06-Mar-2000 enami

branches: 1.41.2;
- Fix a typo that when group_from_gid is failed (though it merely fails
on NetBSD), numeric gid string is used as `user'.
- Don't mix use %u and %d for numeric uid/gid.
- Share temporary buffer.


# 1.40 09-Nov-1999 drochner

Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.


# 1.39 02-Nov-1999 tron

Call setlocale(3) to use localization in "ls" as suggested by
Jens A Nilsson in PR bin/8730.


# 1.38 17-May-1999 lukem

branches: 1.38.2;
Rename ls.c::main() -> ls.c::ls_main(), and add a wrapper in main.c::main().
This allows other programs to link in against ls (e.g, ftpd), without having
to have hacks to deal with multiple main()s.

Yes, I know this is ugly. The clean alternative (move lots of this
into libutil, yada yada yada) isn't fun, and the effort probably isn't
justified...


# 1.37 04-May-1999 simonb

If an error is encountered, exit with non-zero status.

Based on FreeBSD fix (in 1996!), and fixes PR bin/7514 from
Jorgen Pehrson.


# 1.36 17-Feb-1999 kleink

branches: 1.36.2;
Add support for the XCU5 -p option (-F restricted to directories).


# 1.35 12-Feb-1999 kleink

Implement 1003.2 -m option (stream output format).


# 1.34 04-Nov-1998 christos

%q -> %ll


# 1.33 04-Nov-1998 christos

include termios.h for struct winsize


# 1.32 12-Oct-1998 wsanchez

Check for NULL value returned by user_from_uid and group_from_gid and DTRT,
rather than crash.


# 1.31 18-Aug-1998 thorpej

Add some braces to make egcs happy.


# 1.30 27-Jul-1998 mycroft

Delint.


# 1.29 27-Jul-1998 mycroft

Delint.


# 1.28 27-Jul-1998 mycroft

Slight code reduction.


# 1.27 27-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.26 16-May-1998 lukem

* blocks can be 64bit (not u_long), so calculate and display accordingly
* cleanup some other typedamage (int is as good as u_long)
* remove unused variables


# 1.25 02-Feb-1998 mycroft

Deal with GCC warning.


# 1.24 18-Jan-1998 lukem

* implement -x; sort columns across the page rather than down the page
* in printcol(), don't bother building an index to the linked list if
only printing one column with printscol()...
* implement -n; prevent [gu]id->name mapping in long listings.
inspired by openbsd, but does *not* imply -l by itself.
* fix sorting with -d (or mismatched types in general). (from openbsd).
* document -g. (from openbsd).


# 1.23 17-Jan-1998 mycroft

Automatically resize the major and minor number fields, and DTRT if the size
field is not the same size.


# 1.22 29-Jul-1997 thorpej

branches: 1.22.2;
Add some casts to printf args to keep the compiler happy on the Alpha.


# 1.21 20-Jul-1997 christos

include <pwd.h> and <grp.h> to bring prototypes into scope.


# 1.20 20-Jul-1997 christos

remove user_from_uid and group_from_gid prototypes.


# 1.19 20-Jul-1997 christos

Fix compiler warnings.
Add WARNS=1


# 1.18 09-Jul-1996 mycroft

Sort FTS_NS entries by name, just so the order is well-defined.


# 1.17 08-Jul-1996 mycroft

Partition FTS_NS entries from others, to avoid confusing qsort().
Don't bother to order the FTS_NS entries amongst themselves.


# 1.16 13-Feb-1996 jtc

branches: 1.16.4;
Changed so that COLUMNS environment variable will override the value
obtained via the TIOCGWINSIZ ioctl. This is required by POSIX.2, see
section 4.39.5.3.


# 1.15 07-Sep-1995 jtc

Sync with 4.4lite2


# 1.14 21-Mar-1995 cgd

convert to new RCS id conventions.


# 1.13 27-Dec-1994 mycroft

Sync with CSRG.


# 1.12 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


# 1.11 07-Apr-1994 jtc

Changed traverse() and display() so that errors are reported when
they are first detected in display(), rather than waiting until later
in traverse().

The old code allowed "Can not read directory" error messages to be
left unreported unless the -R (recurse) option was used.


# 1.10 04-Apr-1994 chopps

"yet" on quad_t/off_t things. (not noticed on i386 becuase of endian I guess.)


# 1.9 25-Jan-1994 cgd

(1) fixup getbsize() calls
(2) convert to use err(), warn(), and warnx(), as appropriate.


# 1.8 05-Dec-1993 mycroft

Patches from Thomas Eberhardt <thomas@mathematik.uni-Bremen.de> to allow
sorting by size.


# 1.7 06-Aug-1993 mycroft

New version from uunet, with -k option readded, and 4.4 ffs--specific stuff
in `#ifdef notyet'.


# 1.6 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.5 26-May-1993 deraadt

previous patch to ls.c wasn't quite correct. This patch from same author.


# 1.4 24-May-1993 deraadt

first environment variable was trounced in the case of
"ls -l". Patch from <bob@obiwan.uucp> Bob Willcox


# 1.3 22-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.1.1.3 07-Sep-1995 jtc

imported from 44lite2


# 1.1.1.2 21-Sep-1994 mycroft

Import original 4.4-Lite version.


# 1.1.1.1 21-Mar-1993 cgd

initial import of 386bsd-0.1 sources


# 1.16.4.1 09-Dec-1996 mycroft

From trunk:
Various changes to make the sorting deterministic (and correct).


# 1.22.2.1 08-Feb-1998 mellon

Pull up 1.23 (mycroft)


# 1.36.2.1 09-Sep-2000 he

Pull up revision 1.37 (requested by hubertf):
Exit with non-zero status if an error was encountered. Fixes
PR#7514.


# 1.38.2.1 27-Dec-1999 wrstuden

Pull up to last week's -current.


# 1.41.2.1 22-Jun-2000 minoura

Sync w/ netbsd-1-5-base.


# 1.59.2.1 26-Aug-2006 riz

Pull up following revision(s) (requested by christos in ticket #53):
bin/df/df.c: revision 1.71
bin/mv/mv.c: revision 1.36
bin/ls/ls.1: revision 1.61
bin/ls/ls.c: revision 1.60
-h and -[mgk] are mutually exclusive. Only use the last specified. [from zafer]
Use one variable instead of 3 flags to hold the scale, so that we don't have
to reset each flag.
from zafer: you can have either -k or -h but not both since it does not make
sense.
- detect buffer overflow.
- if we have a trailing slash, don't add another one.


# 1.63.12.1 17-Sep-2008 wrstuden

Sync with wrstuden-revivesa-base-2.


# 1.65.6.1 13-May-2009 jym

Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html


# 1.69.8.2 19-Aug-2014 tls

Rebase to HEAD as of a few days ago.


# 1.69.8.1 24-Feb-2013 tls

resync with head


# 1.69.2.2 22-May-2014 yamt

sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")


# 1.69.2.1 15-Jan-2013 yamt

sync with (a bit old) head