Commit Graph

47 Commits

Author SHA1 Message Date
Josef Karthauser
c1499cf6cf 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
2001-12-28 18:14:50 +00:00
Brian Feldman
7304f61f9e Add LOMAC options (the "Z" flag in both cases) to display extra information
in ls(1) and ps(1).

Sponsored by:	DARPA, NAI Labs
2001-11-26 22:21:15 +00:00
Josef Karthauser
d4413063b3 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).
2000-08-13 12:17:03 +00:00
Josef Karthauser
74e6090127 Correct spelling: depricated -> deprecated. 2000-08-12 23:53:11 +00:00
Josef Karthauser
3d2ddc9e1a 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
2000-08-12 22:40:14 +00:00
Assar Westerlund
ee579ffbea 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
2000-07-04 23:09:23 +00:00
Josef Karthauser
141d77b8cb Switch over to using the new fflagstostr and strtofflags library calls. 2000-06-17 14:19:33 +00:00
Andrey A. Chernov
18d8a22b61 Fix one conditionalization in my prev. commit 2000-06-06 13:02:52 +00:00
Andrey A. Chernov
22ff3e9e29 Greately simplify oxtabs fix by simple setting f_notabs for f_color 2000-06-06 12:44:29 +00:00
Andrey A. Chernov
fd4e4d608f Move colorquit() prototype to extern.h
Add "extern" to variables declarations in extern.h to not make them
commons into each compiled file.
2000-06-06 07:14:01 +00:00
Martin Cracauer
ab08444f95 Do SIGINT cleanup for SIGQUIT as well. 2000-06-05 20:38:47 +00:00
Andrey A. Chernov
bd82d8ab8f Don't use curses includes, include termcap.h instead
Add ^C reaction set
2000-06-05 19:36:06 +00:00
Josef Karthauser
5a890e22bf 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
2000-06-05 03:51:29 +00:00
Josef Karthauser
74985094ef * 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.
2000-06-05 02:14:01 +00:00
Josef Karthauser
3885812c8c 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.
2000-06-02 14:53:42 +00:00
Josef Karthauser
418d67b0d9 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
2000-02-05 18:42:36 +00:00
Josef Karthauser
18c0eeddf7 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 ;)
2000-01-27 21:17:01 +00:00
Peter Wemm
2a4562393f $Id$ -> $FreeBSD$ 1999-08-27 23:15:48 +00:00
Chris Costello
279fdba6f6 Backed out my -n change to imply -l by request of sheldonh. 1999-08-23 05:39:40 +00:00
Chris Costello
c9392e0135 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
1999-08-23 01:17:58 +00:00
Sheldon Hearn
1f94b77952 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
1999-08-19 13:04:08 +00:00
Sheldon Hearn
008a491079 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
1999-08-19 11:36:12 +00:00
Sheldon Hearn
f3a6a64e4a 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
1999-08-02 14:55:58 +00:00
Kris Kennaway
46be34b902 Various spelling/formatting changes.
Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
1999-05-08 10:22:15 +00:00
Tim Vanderhoek
bb2b4fafae Add missing "else", without whom the prev. commit is a null change.
Fix a 2nd level indentation style bug.
1998-08-02 22:47:11 +00:00
Tim Vanderhoek
545f583c55 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>
1998-07-29 00:46:13 +00:00
Dag-Erling Smørgrav
a2a029d24a Remove the bogus -? option after reading the getopt() manual :) 1998-04-24 20:15:43 +00:00
Dag-Erling Smørgrav
3a34dbf728 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
1998-04-24 12:43:26 +00:00
Dag-Erling Smørgrav
0d86878ce0 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.
1998-04-24 07:49:51 +00:00
Dag-Erling Smørgrav
7ea3064820 Added -b option to display unprintables in octal.
PR: 1315
1998-04-21 22:02:01 +00:00
Sean Eric Fagan
51f26ac519 Fix sorting of directories when doing '-d'.
PR:		bin/4558
Submitted by:	Keith Bostic
1997-09-18 06:42:27 +00:00
Steve Price
febad2fcf4 Observe precedence set by Phillippe Charnier in adding an
rcsid.
1997-08-07 22:28:25 +00:00
Steve Price
d46c1a60d3 Remove #if(n)def BSD_4_4_LITE cruft and sccsid -> rcsid. 1997-08-07 15:33:50 +00:00
Warner Losh
93ef08af3e compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-28 15:24:41 +00:00
Peter Wemm
b97fa2ef50 Revert $FreeBSD$ to $Id$ 1997-02-22 14:13:04 +00:00
Jordan K. Hubbard
1130b656e5 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.
1997-01-14 07:20:47 +00:00
Steve Price
fb5cb2083a 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.
1996-12-14 06:03:29 +00:00
Adam David
fb1000d678 set error status on exit, to be consistent with manpage and standard commands. 1996-08-27 21:51:48 +00:00
Andrey A. Chernov
f5bd01c69e Change locale to LC_ALL, there no bitmask 1995-10-26 10:56:38 +00:00
Andrey A. Chernov
1d06ee4a64 Change LC_ALL to LC_CTYPE|LC_TIME - small optimization 1995-10-23 21:09:01 +00:00
Andrey A. Chernov
a409ec1917 Add setlocale LC_ALL 1995-10-23 20:36:26 +00:00
Poul-Henning Kamp
90b0ec316f Having BLOCKSIZE=K and using "-k" option ls would use 2K block size... 1995-03-23 19:05:00 +00:00
Joerg Wunsch
0fd510b71a 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)
1995-03-19 13:29:28 +00:00
Joerg Wunsch
34994fcd8e 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
1994-12-18 19:00:01 +00:00
David Greenman
89730b290a Added $Id$ 1994-09-24 02:59:15 +00:00
Paul Traina
475727a09f 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.
1994-09-19 07:49:56 +00:00
Rodney W. Grimes
4b88c807ea BSD 4.4 Lite bin Sources 1994-05-26 06:18:55 +00:00