[Tcsh] various color ls-F fixes

Luke Mewburn luke at mewburn.net
Sun Mar 12 09:25:32 UTC 2023

I noticed that the color ls-F support had various niggles and bugs,
especially with the GNU ls LS_COLORS or FreeBSD/macOS ls LSCOLORS,
so I fixed the problems.

I've created a pull request with a bunch of changes related to color ls-F:


- Improve color ls-F documentation
	- clarify missing is for orphaned (broken) symlinks
	- document LSCOLORS (it previous wasn't)

- Extended the testsuite:
	- added more comments and keywords (-k ...)
	- move ls-F tests to own ls-F.at
	- add color ls-F tests (see CLICOLOR_FORCE)

- On startup, use LS_COLORS in preference to LSCOLORS. This is a
  behaviour change, but given that LS_COLORS provides more features
  than LSCOLORS, platforms generally only set one or the other,
  tcsh had LS_COLORS first, and LSCOLORS wasn't documented,
  I thought it was a reasonble change.

- Implement CLICOLOR_FORCE, to force color ls even if output isn't
  to a terminal.  This was needed for the color ls-F testsuite.
  I followed the FreeBSD / macOS behaviour (which uses the presence
  to enable force), because that appears to be the original canonical
  implementation. Some random websites claim it should be
  CLICOLOR_FORCE=1 and CLICOLOR_FORCE=0 disables, but there wasn't
  an obvious example of prior art.

- Fix LSCOLORS bold mode support. The bug appears to be in original
  LSCOLORS implementation in commit dcedb93 on 2012-06-21 (which
  determined the bold status but didn't use it), and my fix partially
  reverted commit abdf5f1 on 2015-05-28 which removed that unused variable.

- Fix 'ls-F directory' when using LS_COLORS ln=target. The new code
  is simpler than the bespoke readlink() chasing - it just uses
  filetype() with stat() instead of lstat().

- Fix resetting of ln=target on unsetenv LS_COLORS or setenv LSCOLORS.

- I updated "Fixes" with sample entries.

In the future I may enhance color ls-F to to support
more features from LSCOLORS / LS_COLORS:

entry 8		su=		setuid executable
entry 9		sg=		setgid executable
entry 10	tw=		directory o+w,+t
entry 11	ow=		directory o+w
 (n/a)		st=		directory +t
 		mh=		regular file extra links
		ca=		file with capability (linux only?)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/tcsh/attachments/20230312/d13475d1/attachment.asc>

More information about the Tcsh mailing list