|
resubmit: use color ls if $CLICOLOR is set: msg#00074gnu.core-utils.bugs
Hi I have remade my patch against coreutils-4.5.10, and this time will paste the patch into the message body as suggested by: <http://www.gnu.org/software/coreutils/> Sorry for not doing things this way the first time, I usually find separate attachments more useful. Please see my original message for discussion of the patch. Thanks ----->8----->8----->8----->8----->8----->8----->8----->8----- --- src/ls.c.orig 2003-03-19 22:26:01.000000000 +1100 +++ src/ls.c 2003-03-19 22:25:24.000000000 +1100 @@ -1368,6 +1368,12 @@ } } + /* Set default color mode to color_if_tty if CLICOLOR is set. */ + if (!getenv ("POSIXLY_CORRECT") && getenv ("CLICOLOR")) + { + print_with_color = color_if_tty; + } + while ((c = getopt_long (argc, argv, "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UX1", long_options, NULL)) != -1) @@ -1601,23 +1607,11 @@ { int i; if (optarg) - i = XARGMATCH ("--color", optarg, color_args, color_types); + print_with_color = XARGMATCH ("--color", optarg, color_args, color_types); else /* Using --color with no argument is equivalent to using --color=always. */ - i = color_always; - - print_with_color = (i == color_always - || (i == color_if_tty - && isatty (STDOUT_FILENO))); - - if (print_with_color) - { - /* Don't use TAB characters in output. Some terminal - emulators can't handle the combination of tabs and - color codes on the same line. */ - tabsize = 0; - } + print_with_color = color_always; break; } @@ -1661,6 +1655,24 @@ } } + /* print_with_color can be set inside the case statement if the + --color option is specified or outside the case statement + if the CLICOLOR environment variable is set, so handle it after + all command line options are processed. */ + if ((print_with_color == color_if_tty) && !isatty (STDOUT_FILENO)) + { + /* If the color mode is color_if_tty, but output is not a + terminal, turn colors off. */ + print_with_color = 0; + } + if (print_with_color) + { + /* Don't use TAB characters in output. Some terminal + emulators can't handle the combination of tabs and + color codes on the same line. */ + tabsize = 0; + } + filename_quoting_options = clone_quoting_options (NULL); if (get_quoting_style (filename_quoting_options) == escape_quoting_style) set_char_quoting (filename_quoting_options, ' ', 1); ----->8----->8----->8----->8----->8----->8----->8----->8----- -- Michael Wardle michael@xxxxxxxxxxxxxx http://endbracket.net/michael |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | patch: use color mode if CLICOLOR is set: 00074, Michael Wardle |
|---|---|
| Next by Date: | Re: patch: use color mode if CLICOLOR is set: 00074, Bob Proulx |
| Previous by Thread: | patch: use color mode if CLICOLOR is seti: 00074, Michael Wardle |
| Next by Thread: | Bug: Symlink removal.: 00074, Seemant Kulleen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |