History log of /freebsd-11-stable/bin/ls/ls.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 337884 16-Aug-2018 kevans

Revert r337826: MFC of ls(1) COLORTERM honoring

It was not ready, and was much-objected-to.


# 337826 15-Aug-2018 kevans

MFC r337506: 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


# 331722 29-Mar-2018 eadler

Revert r330897:

This was intended to be a non-functional change. It wasn't. The commit
message was thus wrong. In addition it broke arm, and merged crypto
related code.

Revert with prejudice.

This revert skips files touched in r316370 since that commit was since
MFCed. This revert also skips files that require $FreeBSD$ property
changes.

Thank you to those who helped me get out of this mess including but not
limited to gonzo, kevans, rgrimes.

Requested by: gjb (re)


# 330897 14-Mar-2018 eadler

Partial merge of the SPDX changes

These changes are incomplete but are making it difficult
to determine what other changes can/should be merged.

No objections from: pfg


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 285734 21-Jul-2015 allanjude

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


# 285437 13-Jul-2015 bapt

Prevent potential integer overflow

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


# 284198 09-Jun-2015 marcel

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

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


# 284162 08-Jun-2015 delphij

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


# 264064 03-Apr-2014 grog

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


# 242840 09-Nov-2012 peter

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


# 242807 08-Nov-2012 grog

Replace spaces with tabs where appropriate.

Reminded by: jh@


# 242725 07-Nov-2012 grog

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


# 242722 07-Nov-2012 grog

Sort option parsing as far as practical.


# 241014 27-Sep-2012 mdf

Fix bin/ build with a 64-bit ino_t.

Original code by: Gleb Kurtsou


# 226546 19-Oct-2011 des

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>


# 226509 18-Oct-2011 des

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


# 225847 28-Sep-2011 ed

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).


# 203665 08-Feb-2010 jh

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


# 202945 24-Jan-2010 jh

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


# 202944 24-Jan-2010 jh

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


# 198056 13-Oct-2009 jilles

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


# 177907 04-Apr-2008 grog

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


# 157101 24-Mar-2006 jhb

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


# 157100 24-Mar-2006 jhb

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).


# 157098 24-Mar-2006 jhb

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


# 152469 16-Nov-2005 ru

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


# 152256 09-Nov-2005 mux

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


# 146924 03-Jun-2005 dd

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


# 139969 10-Jan-2005 imp

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


# 130237 08-Jun-2004 das

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


# 130029 03-Jun-2004 le

Plug small memory leak.

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


# 127958 06-Apr-2004 markm

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


# 123089 01-Dec-2003 obrien

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

Approved by: re(scottl)


# 114583 03-May-2003 markm

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

Tested on: i386, alpha


# 114047 26-Apr-2003 rwatson

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


# 108057 18-Dec-2002 rwatson

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


# 106479 05-Nov-2002 tjr

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


# 106053 27-Oct-2002 wollman

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


# 105836 23-Oct-2002 rwatson

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


# 105832 23-Oct-2002 rwatson

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


# 105390 18-Oct-2002 tjr

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


# 103726 20-Sep-2002 wollman

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


# 102410 25-Aug-2002 charnier

Replace various spellings with FALLTHROUGH which is lint()able


# 101677 11-Aug-2002 schweikh

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


# 99744 10-Jul-2002 dillon

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.


# 99109 30-Jun-2002 obrien

Consistently use __FBSDID


# 97803 04-Jun-2002 tjr

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


# 96892 19-May-2002 tjr

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>


# 96681 15-May-2002 billf

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

add break statements to default cases where missing.

Submitted by: bde


# 96649 15-May-2002 jmallett

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.


# 96648 15-May-2002 jmallett

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


# 90878 18-Feb-2002 imp

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


# 90153 03-Feb-2002 markm

Use __FBSDID() and clean up the vendor tags.


# 90150 03-Feb-2002 markm

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


# 90115 02-Feb-2002 imp

Fix unused variable.


# 90110 02-Feb-2002 imp

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.


# 88603 28-Dec-2001 joe

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

PR: bin/28007


# 88602 28-Dec-2001 joe

Restore these files to shiny KNF.


# 88591 28-Dec-2001 joe

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


# 88587 28-Dec-2001 joe

Mop up some warnings.


# 88583 28-Dec-2001 joe

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


# 86922 26-Nov-2001 green

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

Sponsored by: DARPA, NAI Labs


# 64604 13-Aug-2000 joe

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).


# 64570 12-Aug-2000 joe

Correct spelling: depricated -> deprecated.


# 64568 12-Aug-2000 joe

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


# 62597 04-Jul-2000 assar

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


# 61749 17-Jun-2000 joe

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


# 61338 06-Jun-2000 ache

Fix one conditionalization in my prev. commit


# 61337 06-Jun-2000 ache

Greately simplify oxtabs fix by simple setting f_notabs for f_color


# 61322 06-Jun-2000 ache

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


# 61295 05-Jun-2000 cracauer

Do SIGINT cleanup for SIGQUIT as well.


# 61289 05-Jun-2000 ache

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


# 61271 05-Jun-2000 joe

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


# 61268 05-Jun-2000 joe

* 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.


# 61178 02-Jun-2000 joe

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.


# 57003 05-Feb-2000 joe

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


# 56692 27-Jan-2000 joe

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 ;)


# 50471 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 50204 23-Aug-1999 chris

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


# 50200 22-Aug-1999 chris

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


# 50051 19-Aug-1999 sheldonh

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


# 50050 19-Aug-1999 sheldonh

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


# 49373 02-Aug-1999 sheldonh

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


# 46684 08-May-1999 kris

Various spelling/formatting changes.

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


# 38026 02-Aug-1998 hoek

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


# 37932 28-Jul-1998 hoek

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>


# 35435 24-Apr-1998 des

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


# 35426 24-Apr-1998 des

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


# 35417 24-Apr-1998 des

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.


# 35373 21-Apr-1998 des

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


# 29560 18-Sep-1997 sef

Fix sorting of directories when doing '-d'.

PR: bin/4558
Submitted by: Keith Bostic


# 27967 07-Aug-1997 steve

Observe precedence set by Phillippe Charnier in adding an
rcsid.


# 27958 07-Aug-1997 steve

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


# 24348 28-Mar-1997 imp

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


# 22988 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21673 14-Jan-1997 jkh

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.


# 20417 14-Dec-1996 steve

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.


# 17852 27-Aug-1996 adam

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


# 11808 26-Oct-1995 ache

Change locale to LC_ALL, there no bitmask


# 11745 23-Oct-1995 ache

Change LC_ALL to LC_CTYPE|LC_TIME - small optimization


# 11740 23-Oct-1995 ache

Add setlocale LC_ALL


# 7282 23-Mar-1995 phk

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


# 7165 19-Mar-1995 joerg

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)


# 5158 18-Dec-1994 joerg

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


# 3044 24-Sep-1994 dg

Added $Id$


# 2889 19-Sep-1994 pst

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.


# 1557 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1556,
which included commits to RCS files with non-trunk default branches.


# 1556 26-May-1994 rgrimes

BSD 4.4 Lite bin Sources