Open bahamas10 opened 6 years ago
GNU ls just takes the values and essentially spits out the control sequences. If you split the LS_COLORS value by semicolon, then you want to print the 'lc' value (default is '\e[', then the value for whatever filetype (no, or a glob match), then the 'rc' value (default is 'm', the filename, then the 'ec' value (I think the default is '\e[0m'.
BSD is completely different of course. illumos doesn't assume all the world is xterm, and converts the LS_COLORS sequences back to color codes and then uses the terminfo database to output the correct sequence.
^ Interesting.... so it appears they all do something different. hm. If node-manta
is to support this, I definitely want it done right and not make any assumptions if we can avoid it.
You could probably go off the existence of either LSCOLOR (BSD) or LS_COLORS (GNU) and prefer which ever one is 'native' if both env vars are present.
I'd have to look more into how
ls
handles it (and how various version ofls
handle it)... but I know off the top of my head there isLS_COLORS
andLSCOLORS
available as env variables... it would be cool ifmls
could use these variables if set, or have its ownMLSCOLORS
, and output color if stdout is a TTY.