History log of /freebsd-current/bin/ls/ls.c
Revision Date Author Comments
# ef75877f 19-Feb-2024 Warner Losh <imp@FreeBSD.org>

ls: Fix -v and associated test

The cleanup of d854370fa86b7 had a cut and paste error (so f_verssort
was set to 1 and then to 0 rather thame f_timesort being set to 0).

Fixes: d854370fa86b7
Sponsored by: Netflix


# d854370f 02-Feb-2024 Alexander Ziaee <concussious@runbox.com>

ls: versort incompatible w/ timesort and sizesort

ls.1: versort incompatible w/ timesort and sizesort

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/825


# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by: Netflix


# 90aea514 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

bin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 3bfbb521 18-Jul-2023 Minsoo Choo <minsoochoo0122@proton.me>

ls: Improve POSIX compatibility for -g and -n.

- Change -g (ignored for BSD 4.3 compatibility since BSD 4.4)
to use POSIX semantics of implying -l but omitting the owner's
name.

- Change -n to imply -l.

The -o option remains unchanged (POSIX defines -o as a complement to
-g that implies -l but omits group names whereas BSD defines -o to add
file flags to -l). This compromise is the same used by both NetBSD
and OpenBSD.

PR: 70813
Reviewed by: jhb, Pau Amma <pauamma@gundo.com>
Co-authored-by: John Baldwin <jhb@FreeBSD.org>
Differential Revision: https://reviews.freebsd.org/D34747


# e2662256 23-Oct-2022 Aymeric Wibo <obiwac@gmail.com>

ls(1): add a -v flag to sort naturally

Add a -v flag for ls which sorts entries following a natural ordering
using strverscmp(3) (e.g. "bloem1 bloem9 bloem10" as opposed to
"bloem1 bloem10 bloem9").

Update the manual page and add a test case.

Reviewed by: pauamma, bcr
Tested by: pstef
Differential Revision: https://reviews.freebsd.org/D36407


# 97c31821 19-Sep-2021 Cameron Katri <me@cameronkatri.com>

ls(1): Allow LSCOLORS to specify an underline

Allows capitalizing the background color character to enable an
underline instead of bold, capitalizing the foreground color char will
still do bold.

Differential Revision: https://reviews.freebsd.org/D30547


# ced2dcad 18-Aug-2021 Piotr Pawel Stefaniak <pstef@FreeBSD.org>

ls: prevent no-color build from complaining when COLORTERM is non-empty

As 257886 reports, if ls(1) is built with WITHOUT_LS_COLORS="YES", it
issues a warning whenever COLORTERM is non-empty. The warning is not
useful, so I thought to remove it, but as Ed pointed out, we may want
to have a way to determine whether a particular copy of ls has been
compiled with color support or not.

Therefore move the warnx() call to the getopt loop in
a WITHOUT_LS_COLORS build to fire when the user asks for colored output.

PR: 257886
Reported by: Marko Turk
Reviewed by: kevans


# 3fee777e 26-Dec-2020 Stefan Eßer <se@FreeBSD.org>

Simplify LS_COLWIDTHS processing

The previous version normalized the width list (replaced empty fields
with "0") just to be able to use sscanf() on the string.

It is much simpler to just parse the string as-is.

The clearing of f_notabs is preserved for the case that less than 9
width values have been defined, but I do not understand the rationale
for this particular condition. E.g., LS_COLWIDTHS="::::::::" will be
counted as 9 defined fields (may clear f_notabs) but is no different
fron LS_COLWIDTHS="" with regard to the field width (and that does not
clear f_notabs, since there are less than 9 fields).


# 2dfa4b66 08-Dec-2020 Bryan Drewery <bdrewery@FreeBSD.org>

fts_read: Handle error from a NULL return better.

This is addressing cases such as fts_read(3) encountering an [EIO]
from fchdir(2) when FTS_NOCHDIR is not set. That would otherwise be
seen as a successful traversal in some of these cases while silently
discarding expected work.

As noted in r264201, fts_read() does not set errno to 0 on a successful
EOF so it needs to be set before calling it. Otherwise we might see
a random error from one of the iterations.

gzip is ignoring most errors and could be improved separately.

Reviewed by: vangyzen
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D27184


# 151a7e11 21-May-2020 Kyle Evans <kevans@FreeBSD.org>

ls: fix WITHOUT_LS_COLORS build

*sigh* references to colorflags should be gated by COLORLS.

Pointy hat to: kevans
Reported by: jenkins (rescue build)
X-MFC-With: r361318


# a408dc20 21-May-2020 Kyle Evans <kevans@FreeBSD.org>

ls(1): actually restore proper behavior

Highlights:
- CLICOLOR in the environment should imply --color=auto to maintain
compatibility with historical behavior
- -G should set CLICOLOR and imply --color=auto

The manpage has been updated to draw the connection between -G and --color;
the former is in-fact a sort of compromise between --color=always and
--color=auto, where we'll output color regardless of the environment lacking
CLICOLOR/COLORTERM assuming stdout is a tty.

X-MFC-With: r361318


# c0f34ded 20-May-2020 Kyle Evans <kevans@FreeBSD.org>

ls: fix a --color regression from r337956

The regression is in-fact that I flipped the default from never to auto. The
incorrect impression was based on an alias that I failed to notice,
installed by the Linux distribution that I used for testing compatibility
here. Users that want the old default should be doing so with a shell alias
as is done elsewhere, rather than making this decision in ls(1).

Many thanks to rgrimes for pointing out the alias that I clearly overlooked
that resulted in this; if you despised colors in your terminal from this,
consider buying him a beer at the next venue that you see him at.

MFC after: 1 week
Relnotes: yes


# 530d2d67 05-May-2020 Conrad Meyer <cem@FreeBSD.org>

ls(1): Fix trivial SEGV due to NULL deref in OOM path

Reported by: Anton Rang <rang AT acm.org>
Sponsored by: Dell EMC Isilon


# 517d0a90 18-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

ls(1): Gate the do_color_* definitions behind COLORLS

Pointy hat to: me


# 041e6eb1 18-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

ls(1): Support other aliases for --color arguments used by GNU ls(1)

These aliases are supported and documented in the man page. For now, they
will not be mentioned in the error when an invalid argument is encountered,
instead keeping that list to the shorter 'preferred' names of each argument.

Reported by: rgrimes


# e10ba800 16-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

ls(1): Add --color=when

--color may be set to one of: 'auto', 'always', and 'never'.

'auto' is the default behavior- output colors only if -G or COLORTERM are
set, and only if stdout is a tty.

'always' is a new behavior- output colors always. termcap(5) will be
consulted unless TERM is unset or not a recognized terminal, in which case
ls(1) will fall back to explicitly outputting ANSI escape sequences.

'never' to turn off any environment variable and -G usage.

Reviewed by: cem, 0mp (both modulo last-minute manpage changes
Differential Revision: https://reviews.freebsd.org/D16741


# 7db2f1fe 15-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

ls(1): Fix color env var checking

CLICOLOR will behavior as always- if present at all in the environment,
allow colors.

COLORTERM, recently enforced, will have to be both present and not empty.

Submitted by: imp


# 33ce7acb 08-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

ls(1): Enable colors with COLORTERM is set in the environment

COLORTERM is the de facto standard, while CLICOLOR is generally specific to
FreeBSD and ls(1).

PR: 230101
Submitted by: D Green <dfrg@xsmail.com> (with manpage additions by myself)
Reviewed by: cem ("LGTM" in PR; pre-manpage changes)
MFC after: 1 week


# 0fdf7fa8 17-Jan-2018 Conrad Meyer <cem@FreeBSD.org>

Convert ls(1) to not use libxo(3)

libxo imposes a large burden on system utilities. In the case of ls, that
burden is difficult to justify -- any language that can interact with json
output can use readdir(3) and stat(2).

Logically, this reverts r291607, r285857, r285803, r285734, r285425,
r284494, r284489, r284252, and r284198.

Kyua tests continue to pass (libxo integration was entirely untested).

Reported by: many
Reviewed by: imp
Discussed with: manu, bdrewery
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13959


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# e5542be4 20-Jul-2015 Allan Jude <allanjude@FreeBSD.org>

Fix some issues with the application of libxo to ls(1)

* Add whitespace trimming to some fields (username, group, size, inode, blocks) to avoid whitespace in JSON strings
* fix -m mode, was invalid JSON (repeated keys), and was missing outer array container
* in -n mode, numeric uids and gids were returned as strings

Approved by: eadler (mentor)
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D2854


# d4bf4151 12-Jul-2015 Baptiste Daroussin <bapt@FreeBSD.org>

Prevent potential integer overflow

PR: 192971
Submitted by: David Carlier <david.carlier@hardenedbsd.org>


# 52e4a08c 09-Jun-2015 Marcel Moolenaar <marcel@FreeBSD.org>

Convert ls(1) to use libxo(3).

Obtained from: Phil Shafer <phil@juniper.net>
Sponsored by: Juniper Networks, Inc.


# 183714f3 08-Jun-2015 Xin LI <delphij@FreeBSD.org>

It has been long time that when doing 'ls -G /path/to/a/symlink', instead of
using the color of symbolic link, the color is determined by the link target.
This behavior was quite confusing.

Looking at the file history, it looks like that r203665 intends to fix this
but the issue was never actually fixed.

Fix this by not setting FTS_COMFOLLOW when color is requested like what was
done in r203665.

MFC after: 2 weeks


# 3651faa5 02-Apr-2014 Greg Lehey <grog@FreeBSD.org>

Make -f set -a, as required by the standard.

From the original OpenBSD commit 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@

Submitted by: Igor Sobrado
Discussed with: mckusick
Obtained from: OpenBSD project
MFC after: 2 weeks


# d272a5b7 09-Nov-2012 Peter Wemm <peter@FreeBSD.org>

Undo over-aggressive conversion of spaces to tabs. ie: those within
format strings, "period, space, space" in comment text, etc.


# dfd91f79 08-Nov-2012 Greg Lehey <grog@FreeBSD.org>

Replace spaces with tabs where appropriate.

Reminded by: jh@


# 9aa68a3f 07-Nov-2012 Greg Lehey <grog@FreeBSD.org>

Add y flag and environment variable LS_SAMESORT to specify the same
sorting order for time and name with the -t option. IEEE Std 1003.2
(POSIX.2) mandates that the -t option sort in descending order, and
that if two files have the same timestamp, they should be sorted in
ascending order of their names. The -r flag reverses both of these
sort orders, so they're never the same. This creates significant
problems for sequentially named files stored on FAT file systems,
where it can be impossible to list them in the order in which they
were created.

Add , (comma) option to print file sizes grouped and separated by
thousands using the non-monetary separator returned by localeconv(3),
typically a comma or period.

MFC after: 14 days


# 44f17a81 07-Nov-2012 Greg Lehey <grog@FreeBSD.org>

Sort option parsing as far as practical.


# 6db1a7f1 27-Sep-2012 Matthew D Fleming <mdf@FreeBSD.org>

Fix bin/ build with a 64-bit ino_t.

Original code by: Gleb Kurtsou


# 4d4dcc7a 19-Oct-2011 Dag-Erling Smørgrav <des@FreeBSD.org>

If ls was invoked with -i but neither -l nor -s, blocksize was used in
display() to calculate column widths, but was not initialized in
main(). This resulted in a division by zero.

Noticed by: Michael Butler <imb@protected-networks.net>


# cf147939 18-Oct-2011 Dag-Erling Smørgrav <des@FreeBSD.org>

When calculating the width of the blocksize column, ls(1) used 512-byte
units (as returned by stat(2)) instead of BLOCKSIZE units.

Submitted by: Paul Schenkeveld
MFC after: 3 weeks


# 9f365aa1 28-Sep-2011 Ed Schouten <ed@FreeBSD.org>

Get rid of major/minor number distinction.

As of FreeBSD 6, devices can only be opened through devfs. These device
nodes don't have major and minor numbers anymore. The st_rdev field in
struct stat is simply based a copy of st_ino.

Simply display device numbers as hexadecimal, using "%#jx". This is
allowed by POSIX, since it explicitly states things like the following
(example taken from ls(1)):

"If the file is a character special or block special file, the
size of the file may be replaced with implementation-defined
information associated with the device in question."

This makes the output of these commands more compact. For example, ls(1)
now uses approximately four columns less. While there, simplify the
column length calculation from ls(1) by calling snprintf() with a NULL
buffer.

Don't be afraid; if needed one can still obtain individual major/minor
numbers using stat(1).


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# e0d5ebc3 28-Feb-2010 Jaakko Heinonen <jh@FreeBSD.org>

MFC r203665:

Make sure that FTS_COMFOLLOW is not set when the -P option is in effect.
Otherwise the -i option will show the inode number of the referenced file
for symbolic links given on the command line. Similarly, the file color
was printed according to the link target in colorized output.

PR: bin/102394


# bb2f41f9 24-Feb-2010 Jaakko Heinonen <jh@FreeBSD.org>

MFC r202945:

Fixes for ls(1) long format (-l) output:

- Allow -h option to work if the listing contains at least one device
file.
- Align major and minor device numbers correctly to the size field.

PR: bin/125678


# 1fe8c2a9 08-Feb-2010 Jaakko Heinonen <jh@FreeBSD.org>

Make sure that FTS_COMFOLLOW is not set when the -P option is in effect.
Otherwise the -i option will show the inode number of the referenced file
for symbolic links given on the command line. Similarly, the file color
was printed according to the link target in colorized output.

PR: bin/102394
Reviewed by: jilles
MFC after: 2 weeks


# 8abe3cc3 31-Jan-2010 Jaakko Heinonen <jh@FreeBSD.org>

MFC r202944:

Print full path in the error message. It's possible that fts(3)
provides an empty fts_name and reporting the full path is more
appropriate especially with the -R option.

PR: bin/107515
Approved by: trasz (mentor)


# 55926a66 24-Jan-2010 Jaakko Heinonen <jh@FreeBSD.org>

Fixes for ls(1) long format (-l) output:

- Allow -h option to work if the listing contains at least one device
file.
- Align major and minor device numbers correctly to the size field.

PR: bin/125678
Approved by: trasz (mentor)
MFC after: 1 month


# ba027bbf 24-Jan-2010 Jaakko Heinonen <jh@FreeBSD.org>

Print full path in the error message. It's possible that fts(3)
provides an empty fts_name and reporting the full path is more
appropriate especially with the -R option.

PR: bin/107515
Submitted by: bde
Approved by: trasz (mentor)
MFC after: 1 week


# 5c3743e3 13-Oct-2009 Jilles Tjoelker <jilles@FreeBSD.org>

ls: Make -p not inhibit following symlinks.

According to the man page, when neither -H/-L nor -F/-d/-l are given, -H is
implied. This agrees with POSIX, GNU ls and Solaris ls. This means that -p,
although it is very similar to -F, does not prevent the implicit following
of symlinks.

PR: standards/128546


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 2269fa57 03-Apr-2008 Greg Lehey <grog@FreeBSD.org>

Add -D option to specify exact format of date and time output with ls -l.


# 93a5035f 24-Mar-2006 John Baldwin <jhb@FreeBSD.org>

Change the -S and -t options to override each other so that the last one
specified wins to make their interaction less confusing.


# 86cca1e7 24-Mar-2006 John Baldwin <jhb@FreeBSD.org>

Fix a bug such that if you enabled sorting by size (-S) and enabled a
flag to use a time other than modtime (-c, -u, or -U), the output would
actually be sorted by the specified time rather than size. This does
alter the behavior in the case where both -S and -t are specified. Now,
-S is always preferred. Previously, -t was preferred if one of -c, -u, or
-U was specified, and -S was preferred otherwise. Perhaps -S and -t should
override each other (last one specified wins).


# fe79420e 24-Mar-2006 John Baldwin <jhb@FreeBSD.org>

Add a new -U flag to instruct ls to use the birthtime for printing or
sorting.

Submitted by: Andrzej Tobola ato at iem dot pw dot edu dot pl
MFC after: 1 week


# 390a478e 16-Nov-2005 Ruslan Ermilov <ru@FreeBSD.org>

Having three options (-a, -A, -I) controlling the output of dotted
files is too much and hard to follow. Instead, make the -I option
just mean "do not automatically set -A for root". That is, if -A
is explicitly set, -I is ignored. Also, document -I in usage().
(The ls.c diff is better viewed relative to rev. 1.80.)

No objection: mux
Silence from: mnag
MFC after: 3 days


# 7b7d153b 09-Nov-2005 Maxime Henrion <mux@FreeBSD.org>

Add a -I option to disable the automatic -A flag for the super-user.

PR: bin/86710
Submitted by: Marcus Alves Grando
MFC after: 3 days


# 71b8b748 03-Jun-2005 Dima Dorfman <dd@FreeBSD.org>

Add the -S option to sort files by size. NetBSD and OpenBSD already
have this option with identical semantics (sorting large files first).
-r can be used to reverse the sort if that is desired.

PR: 81625
Submitted by: Kostas Blekos <mplekos@physics.upatras.gr>, keramida


# 9ddb49cb 10-Jan-2005 Warner Losh <imp@FreeBSD.org>

/*- or .\"- or #- to begin license clauses.


# 70bad4f7 08-Jun-2004 David Schultz <das@FreeBSD.org>

If we are asked to print the total number of blocks, do so even if we
have no entries to print (either due to an empty directory or an
error). This makes the -l and -s options more consistent, like
Solaris and (Debian) Linux. To make this happen, tweak two
optimizations on the second call to display():

- Don't skip display() altogether, even if list == NULL.
- Don't skip the call to the printfn in display() if we
need to print the total.

PR: 45723


# 7fcc4669 03-Jun-2004 Lukas Ertl <le@FreeBSD.org>

Plug small memory leak.

PR: bin/67392
Submitted by: Matthew Emmerton <matt@gsicomp.on.ca>
MFC in: 1 week


# 6195fb41 06-Apr-2004 Mark Murray <markm@FreeBSD.org>

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


# d5f9f41c 01-Dec-2003 David E. O'Brien <obrien@FreeBSD.org>

Do something sensible if both -h and -k are given.

Approved by: re(scottl)


# 40feca3a 03-May-2003 Mark Murray <markm@FreeBSD.org>

Fix a bazillion warnings. This makes almost the whole of src/bin/*
WARNS=6, std=c99 clean.

Tested on: i386, alpha


# 317f1d53 25-Apr-2003 Robert Watson <rwatson@FreeBSD.org>

When mac_from_text() fails with -Z, print "-" rather than "" so that
scripts parsing ls(1) output can still count columns.

Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories


# 3c3f5f9c 18-Dec-2002 Robert Watson <rwatson@FreeBSD.org>

Improve handling of symlink targets when listing MAC labels: don't
do the wrong thing when the symlink doesn't have a target, by
considering !f_label in the construction of ch_options.

Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories


# e09fdabd 05-Nov-2002 Tim J. Robbins <tjr@FreeBSD.org>

Use warn() instead of perror() or fprintf() where appropriate.


# 688dfe45 27-Oct-2002 Garrett Wollman <wollman@FreeBSD.org>

Do not include <sys/syslimits.h> directly; it is not intended for general
consumption.


# 4df6daba 23-Oct-2002 Robert Watson <rwatson@FreeBSD.org>

Attempt improved use of fts results: use the correct path to the
object to retrieve label information on, rather than directly
consuming the fts-provided paths (none of which are quite right).
This is based on the similar readlink() code, and may contain
the same bugs.

Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories


# 4d33b62e 23-Oct-2002 Robert Watson <rwatson@FreeBSD.org>

Teach "ls -Z" to use the policy-agnostic MAC label interfaces rather
than the LOMAC-specific interfaces for listing MAC labels. This permits
ls to view MAC labels in a manner similar to getfmac, when ls is used
with the -l argument. Next generation LOMAC will use the MAC Framework
so should "just" work with this and other policies. Not the prettiest
code in the world, but then, neither is ls(1).

Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories


# 1656f850 18-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

Print non-printing characters in directory names, as well as file names,
as `?' or `\ooo', depending on whether the -b or -B flags were used.

PR: 43995
MFC after: 1 month


# 0d3bcc2e 20-Sep-2002 Garrett Wollman <wollman@FreeBSD.org>

Make the threatened fts(3) ABI fix. FTSENT now avoids the use of the struct
hack, thereby allowing future extensions to the structure (e.g., for extended
attributes) without rebreaking the ABI. FTSENT now contains a pointer to the
parent stream, which fts_compar() can then take advantage of, avoiding the
undefined behavior previously warned about. As a consequence of this change,
the prototype of the comparison function passed to fts_open() has changed
to reflect the required amount of constness for its use. All callers in the
tree are updated to use the correct prototype.

Comparison functions can now make use of the new parent pointer to access
the new stream-specific private data pointer, which is intended to assist
creation of reentrant library routines which use fts(3) internally.

Not objected to in spirit by: -arch


# 0d9f1a69 25-Aug-2002 Philippe Charnier <charnier@FreeBSD.org>

Replace various spellings with FALLTHROUGH which is lint()able


# 2b239dd1 11-Aug-2002 Jens Schweikhardt <schweikh@FreeBSD.org>

Fix typos; each file has at least one s/seperat/separat/
(I skipped those in contrib/, gnu/ and crypto/)
While I was at it, fixed a lot more found by ispell that I
could identify with certainty to be errors. All of these
were in comments or text, not in actual code.

Suggested by: bde
MFC after: 3 days


# 5ad9e45f 10-Jul-2002 Matthew Dillon <dillon@FreeBSD.org>

err() is documented as allowing NULL for the format string but GCC isn't
happy about it any more so change the usage to make buildworld work again.


# 5eb43ac2 29-Jun-2002 David E. O'Brien <obrien@FreeBSD.org>

Consistently use __FBSDID


# a28edf9a 04-Jun-2002 Tim J. Robbins <tjr@FreeBSD.org>

Ignore empty COLUMNS environment variable. COLUMNS should take precedence
over TTY width found via ioctl() (SUSv3)


# 94274c73 18-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

Add missing options required by SUSv3:
-m List files across the page, separated by commas.
-p Print a slash after directory names
-x Same as -C but sort across the columns rather than down

Submitted by: Kyle Martin <mkm@ieee.org>


# 568dcd5f 15-May-2002 Bill Fumerola <billf@FreeBSD.org>

restore missing default case removed in ls.c:r1.57

add break statements to default cases where missing.

Submitted by: bde


# 0928a7f1 15-May-2002 Juli Mallett <jmallett@FreeBSD.org>

Make 'user' and 'group' const as to not discard the qualifier from the
functions we use to assign them. Doesn't seem to be anything else that
relies on these being non-const.


# ff5e2533 15-May-2002 Juli Mallett <jmallett@FreeBSD.org>

Remove an empty default case to make this syntactically correct. Not there
is as good as blaknk.


# 576541a9 18-Feb-2002 Warner Losh <imp@FreeBSD.org>

Fixed divots that I created when I moved prototypes of group_from_gid
and user_from_uid to grp.h and pwd.h. Update the man pages.

Submitted by: David Malone
Pointy hat to: imp


# c73d77ce 03-Feb-2002 Mark Murray <markm@FreeBSD.org>

Use __FBSDID() and clean up the vendor tags.


# 9052855a 03-Feb-2002 Mark Murray <markm@FreeBSD.org>

WARNS=4 fixes, plus a healthy dose of fixes inspired by lint.


# 900021ae 02-Feb-2002 Warner Losh <imp@FreeBSD.org>

Fix unused variable.


# 46251dde 01-Feb-2002 Warner Losh <imp@FreeBSD.org>

o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
they already are.


# 47f884f0 28-Dec-2001 Josef Karthauser <joe@FreeBSD.org>

Force raw printing of non-printable characters via the -w option.

PR: bin/28007


# 5dda5d0d 28-Dec-2001 Josef Karthauser <joe@FreeBSD.org>

Restore these files to shiny KNF.


# 0e8d1551 28-Dec-2001 Josef Karthauser <joe@FreeBSD.org>

Add a new flag, -h which when combined with the -l option causes
file sizes to be displayed with unit suffixes; Byte, Kilobyte,
Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the
number of digits to three or less.

Submitted by: nik


# 6bd042df 28-Dec-2001 Josef Karthauser <joe@FreeBSD.org>

Mop up some warnings.


# c1499cf6 28-Dec-2001 Josef Karthauser <joe@FreeBSD.org>

Revamp the colour support to allow for bold characters. Colours
are now defined using the characters a-h and A-H for the bold
variants. The old way using 0-7 for the colours still works, but
prints a message asking the user to switch.

PR: bin/27374


# 7304f61f 26-Nov-2001 Brian Feldman <green@FreeBSD.org>

Add LOMAC options (the "Z" flag in both cases) to display extra information
in ls(1) and ps(1).

Sponsored by: DARPA, NAI Labs


# d4413063 12-Aug-2000 Josef Karthauser <joe@FreeBSD.org>

Un-deprecate the -G flag at obrien's request. Colour sequences are still
dependent upon the output being directed to a terminal however.
(Use the CLICOLOR_FORCE variable to force output).


# 74e60901 12-Aug-2000 Josef Karthauser <joe@FreeBSD.org>

Correct spelling: depricated -> deprecated.


# 3d2ddc9e 12-Aug-2000 Josef Karthauser <joe@FreeBSD.org>

A change to the way that colours are switched on in ls. The -G
flag has been depricated, although it still works with a warning
message, and replaced with an environment variable CLICOLOR (command
line interface colour). This could be used by other tools that
want to be able to control colour output.

In addition if the environment variable CLICOLOR_FORCE is defined
colour sequences are output irrespective of whether the output is
directed to a terminal (as long as TERM references a colour capable
terminal of course ;)

PR: bin/20291 and bin/20483


# ee579ffb 04-Jul-2000 Assar Westerlund <assar@FreeBSD.org>

make sure we do not write out non-printable characters in file names
and symbolic links (by default)

PR: bin/19354
Reviewed by: silence on -current


# 141d77b8 17-Jun-2000 Josef Karthauser <joe@FreeBSD.org>

Switch over to using the new fflagstostr and strtofflags library calls.


# 18d8a22b 06-Jun-2000 Andrey A. Chernov <ache@FreeBSD.org>

Fix one conditionalization in my prev. commit


# 22ff3e9e 05-Jun-2000 Andrey A. Chernov <ache@FreeBSD.org>

Greately simplify oxtabs fix by simple setting f_notabs for f_color


# fd4e4d60 06-Jun-2000 Andrey A. Chernov <ache@FreeBSD.org>

Move colorquit() prototype to extern.h
Add "extern" to variables declarations in extern.h to not make them
commons into each compiled file.


# ab08444f 05-Jun-2000 Martin Cracauer <cracauer@FreeBSD.org>

Do SIGINT cleanup for SIGQUIT as well.


# bd82d8ab 05-Jun-2000 Andrey A. Chernov <ache@FreeBSD.org>

Don't use curses includes, include termcap.h instead
Add ^C reaction set


# 5a890e22 04-Jun-2000 Josef Karthauser <joe@FreeBSD.org>

Don't look up the ANSI sequences each time a colour is changed,
this is extremely inefficient, instead write them all down at the
beginning.

The correct sequence to switch colours off is to first use 'op' if
it exists, otherwise use 'oc'. If neither of these exist then we
shouldn't be doing colour with this terminal.

Reviewed by: ache


# 74985094 04-Jun-2000 Josef Karthauser <joe@FreeBSD.org>

* Re-implement colour support using termcap's AF and AB capabilities
to manage the ANSI colour sequences. Colour support is disabled
unless the TERM environment variable references a valid termcap.

* Allow optional compilation of the colour support in the Makefile,
defaulting to yes. This allows us to switch it off for fixit
floppies and other mediums where space is an issue and the extra
bloat of statically linking with ncurses isn't acceptable.

* Display a warning if colour is requested with '-G' but support
for it isn't compiled in.


# 3885812c 02-Jun-2000 Josef Karthauser <joe@FreeBSD.org>

Add colour support to /bin/ls (at a cost of 1056 bytes on my system).

It is not switched on by default and must be enabled with the -G
flag. When using ls -G the output behaviour is modified with ANSI
colour sequences wrapped around filenames to help distinguish file
types. (Colours can be redefined in the LSCOLORS environment
variable as described in the manual page.)

Colour support is silently disabled (if switched on) if stdout
isn't a tty.

Based on: asami's colorls port.
PR: bin/18900 && ports/18616.


# 418d67b0 05-Feb-2000 Josef Karthauser <joe@FreeBSD.org>

Revert part of the last commit, remove {g|s}etflags from the libc
interface, and statically link them to the programs using them.
These functions, upon reflection and discussion, are too generically
named for a library interface with such specific functionality.
Also the api that they use, whilst ok for private use, isn't good
enough for a libc function.

Additionally there were complications with the build/install-world
process. It depends heavily upon xinstall, which got broken by
the change in api, and caused bootstrap problems and general mayhem.

There is work in progress to address future problems that may be
caused by changes in install-chain tools, and better names for
{g|s}etflags can be derived when some future program requires them.
For now the code has been left in src/lib/libc/gen (it started off
in src/bin/ls).

It's important to provide library functions for manipulating file
flag strings if we ever want this interface to be adopted outside
of the source tree, but now isn't necessarily the right moment
with 4.0-release just around the corner.

Approved: jkh


# 18c0eedd 27-Jan-2000 Josef Karthauser <joe@FreeBSD.org>

Historically file flags (schg, uschg, etc) have been converted from
string to u_long and back using two functions, flags_to_string and
string_to_flags, which co-existed with 'ls'. As time has progressed
more and more other tools have used these private functions to
manipulate the file flags.

Recently I moved these functions from /usr/src/bin/ls to libutil,
but after some discussion with bde it's been decided that they
really ought to go in libc.

There are two already existing libc functions for manipulating file
modes: setmode and getmode. In keeping with these flags_to_string
has been renamed getflags and string_to_flags to setflags.

The manual page could probably be improved upon ;)


# 2a456239 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 279fdba6 22-Aug-1999 Chris Costello <chris@FreeBSD.org>

Backed out my -n change to imply -l by request of sheldonh.


# c9392e01 22-Aug-1999 Chris Costello <chris@FreeBSD.org>

Make -n flag compliant to the Single Unix Specification.

To quote their ls(1) specification:

-n
The same as -l, except that the owner's UID and GID numbers are
written, rather than the associated character strings.

Reviewed by: green


# 1f94b779 19-Aug-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Take integer rounding into account in the buffer size approximation
macro. So now it's (1 +) for the sign and (+ 1) for rounding.

Reported by: bde


# 008a4910 19-Aug-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Style issues in previous commit:

Use an upward approximation of the number of characters required
for decimal representations of uid_t, gid_t and u_quad_t, intead
of arbitrary values that may not be safe in the future.

Fix disordering.

Requested by: bde


# f3a6a64e 02-Aug-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Add -n option to print numeric user and group IDs instead of names
in a long (-l) listing.

MFC-jockies should make sure that bde's concerns regarding the number
of digits required to represent a uid_t and the use of snprintf
on the associated PR have been addressed before going wild.

PR: 12866
Reported by: Philip Kizer <pckizer@nostrum.com>
Obtained from: NetBSD


# 46be34b9 08-May-1999 Kris Kennaway <kris@FreeBSD.org>

Various spelling/formatting changes.

Submitted by: Philippe Charnier <charnier@xp11.frmug.org>


# bb2b4faf 02-Aug-1998 Tim Vanderhoek <hoek@FreeBSD.org>

Add missing "else", without whom the prev. commit is a null change.
Fix a 2nd level indentation style bug.


# 545f583c 28-Jul-1998 Tim Vanderhoek <hoek@FreeBSD.org>

Allow env. variable LS_COLWIDTHS to specify minimum column widths,
effectively overriding the dynamically-sized-column feature. This
is mostly useful for non-interactive use, where it may be necessary
to ensure that listings taken at different times have columns that
line-up correctly. I have been assured that at least one large,
well-known program will soon be taking advantage of this. :-)

PR: bin/7011
Submitted by: Joel Ray Holveck <joelh@gnu.org>


# a2a029d2 24-Apr-1998 Dag-Erling Smørgrav <des@FreeBSD.org>

Remove the bogus -? option after reading the getopt() manual :)


# 3a34dbf7 23-Apr-1998 Dag-Erling Smørgrav <des@FreeBSD.org>

o Removed two unused variables (f_dirname and f_newline) in ls.c

o Added the -H and -P options for treatment of symbolic links.

o Removed the #ifdef BSD4_4_LITE, since it does not seem to do anything
useful

o Fixed up prn_octal() so its output looks more like that of AT&T Unices
when -b is given.

The next two lines apply only to the first two changes above:

PR: bin/6140
Submitted by: Max Euston


# 0d86878c 24-Apr-1998 Dag-Erling Smørgrav <des@FreeBSD.org>

o Renamed '-b' (show unprintables in octal) to '-B'

o Added a new '-b' which behaves as in AT&T Unices (show unprintables in
octal, using C escape codes when possible)

o Added '?' to the getopt() string, since the code in the switch considers
it as a valid option.


# 7ea30648 21-Apr-1998 Dag-Erling Smørgrav <des@FreeBSD.org>

Added -b option to display unprintables in octal.
PR: 1315


# 51f26ac5 18-Sep-1997 Sean Eric Fagan <sef@FreeBSD.org>

Fix sorting of directories when doing '-d'.

PR: bin/4558
Submitted by: Keith Bostic


# febad2fc 07-Aug-1997 Steve Price <steve@FreeBSD.org>

Observe precedence set by Phillippe Charnier in adding an
rcsid.


# d46c1a60 07-Aug-1997 Steve Price <steve@FreeBSD.org>

Remove #if(n)def BSD_4_4_LITE cruft and sccsid -> rcsid.


# c4694019 01-Jul-1997 Bruce Evans <bde@FreeBSD.org>

Import Lite2's src/bin. All files in src/bin are off the vendor branch,
so this doesn't change the active versions.


# 93ef08af 28-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# b97fa2ef 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# fb5cb208 13-Dec-1996 Steve Price <steve@FreeBSD.org>

Merge Lite2 mods, and -Wall cleaning. undelete(2) cruft
not yet implemented is protected by a define (BSD4_4_LITE)
that should be removed when this call is supported by the
kernel.


# fb1000d6 27-Aug-1996 Adam David <adam@FreeBSD.org>

set error status on exit, to be consistent with manpage and standard commands.


# f5bd01c6 26-Oct-1995 Andrey A. Chernov <ache@FreeBSD.org>

Change locale to LC_ALL, there no bitmask


# 1d06ee4a 23-Oct-1995 Andrey A. Chernov <ache@FreeBSD.org>

Change LC_ALL to LC_CTYPE|LC_TIME - small optimization


# a409ec19 23-Oct-1995 Andrey A. Chernov <ache@FreeBSD.org>

Add setlocale LC_ALL


# 90b0ec31 23-Mar-1995 Poul-Henning Kamp <phk@FreeBSD.org>

Having BLOCKSIZE=K and using "-k" option ls would use 2K block size...


# 0fd510b7 19-Mar-1995 Joerg Wunsch <joerg@FreeBSD.org>

You will find enclosed some changes to make gcc -Wall more happy in
/usr/src/bin. Note that some patches are still needed in that directory.

I (Joerg) finished most of Philippe's cleanup. /bin/sh will still
need *allot* of work, however.

Submitted by: charnier@lirmm.fr (Philippe Charnier)


# 34994fcd 18-Dec-1994 Joerg Wunsch <joerg@FreeBSD.org>

Make ls recognize the COLUMNS environmental variable, even
in cases where it does not run on a terminal. This is important
e.g. for commands like

env COLUMNS=132 ls -CR | lpr -Psome-wide-printer


# 89730b29 23-Sep-1994 David Greenman <dg@FreeBSD.org>

Added $Id$


# 475727a0 19-Sep-1994 Paul Traina <pst@FreeBSD.org>

Add support for '-k' option to print file allocation space in 'K' instead of
system blocks.

This is semi-original code, not the same way this crufty option was handled
in FreeBSD 1.x.


# 4b88c807 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite bin Sources