From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 28 15:31:55 2013 Received: (at submit) by debbugs.gnu.org; 28 Nov 2013 20:31:55 +0000 Received: from localhost ([127.0.0.1]:49216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vm8Ff-0003Pf-Bo for submit@debbugs.gnu.org; Thu, 28 Nov 2013 15:31:55 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39397) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vm8Fd-0003PP-Oi for submit@debbugs.gnu.org; Thu, 28 Nov 2013 15:31:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm8FP-0004M4-WE for submit@debbugs.gnu.org; Thu, 28 Nov 2013 15:31:48 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:34148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm8FP-0004M0-TW for submit@debbugs.gnu.org; Thu, 28 Nov 2013 15:31:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm8FJ-0003cv-TE for bug-coreutils@gnu.org; Thu, 28 Nov 2013 15:31:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm8FD-0004KM-Pr for bug-coreutils@gnu.org; Thu, 28 Nov 2013 15:31:33 -0500 Received: from ishtar.tlinx.org ([173.164.175.65]:45046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm8FD-0004Hb-IY for bug-coreutils@gnu.org; Thu, 28 Nov 2013 15:31:27 -0500 Received: from [192.168.4.12] (Athenae [192.168.4.12]) by Ishtar.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id rASKV7ef005411 for ; Thu, 28 Nov 2013 12:31:09 -0800 Message-ID: <5297A80A.3090903@tlinx.org> Date: Thu, 28 Nov 2013 12:31:06 -0800 From: Linda Walsh User-Agent: Thunderbird MIME-Version: 1.0 To: bug-coreutils@gnu.org Subject: 'ls' ignores term capabilities when generating color. Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) I logged in on a *dumb* terminal and did an 'ls'. Rather than a file list, I got: \x1b[00;32mwpad.dat\x1b[0m* \x1b[00mwpad_socks.dat\x1b[0m \x1b[00mwuredir.xml\x1b[0m \x1b[00mx.c\x1b[0m \x1b[00mx.c.orig\x1b[0m \x1b[00;32mx1\x1b[0m* \x1b[00mxaml\x1b[0m \x1b[01;35mxmision-web\x1b[0m/ \x1b[01;35mxrdp\x1b[0m/ \x1b[00mxrdp-sesadmin.log\x1b[0m \x1b[00;32mxtree117.zip\x1b[0m* \x1b[00;32mxtree2b-20050606.zip\x1b[0m* \x1b[01;35mxx\x1b[0m/ \x1b[01;35mxxx\x1b[0m/ \x1b[00;32myast2.txt\x1b[0m* \x1b[40;33;01mzero\x1b[0m \x1b[01;35mzips\x1b[0m/ \x1b[01;35mztars\x1b[0m/ \x1b[01;35mztest\x1b[0m/ \x1b[00mzyppinst\x1b[0m ------------------ While I do have an alias that says: alias ls='ls -CF --show-control-chars --color=always' If the terminal HAS NO color capabilities, I would expect it not to display anything where color was selected, as the mapping for switching colors on a dumb terminal is "". I tried settings for "TERM": of "none", "dumb", and "" (empty) All gave the same strings as would be correct for a 16-color terminal. IMO, "ls" shouldn't print out "bogus" strings for color that are not in the listed "TERM"inal's capabilties. Wouldn't that be the wisest course of action? Or is there a requirement, "poSomewhereIx" to print garbage strings to terminals that don't have specific capabilities? ;-) From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 28 16:35:59 2013 Received: (at submit) by debbugs.gnu.org; 28 Nov 2013 21:35:59 +0000 Received: from localhost ([127.0.0.1]:49256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vm9Ff-000568-C1 for submit@debbugs.gnu.org; Thu, 28 Nov 2013 16:35:59 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50515) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vm9Fd-00055w-9R for submit@debbugs.gnu.org; Thu, 28 Nov 2013 16:35:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm9FP-0007La-Lx for submit@debbugs.gnu.org; Thu, 28 Nov 2013 16:35:52 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:51680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm9FP-0007LW-If for submit@debbugs.gnu.org; Thu, 28 Nov 2013 16:35:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm9FI-0003Lw-UG for bug-coreutils@gnu.org; Thu, 28 Nov 2013 16:35:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm9FC-0007Ki-T9 for bug-coreutils@gnu.org; Thu, 28 Nov 2013 16:35:36 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:46466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm9FC-0007Ke-NJ for bug-coreutils@gnu.org; Thu, 28 Nov 2013 16:35:30 -0500 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 44E3733F227; Thu, 28 Nov 2013 21:35:29 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: bug-coreutils@gnu.org Subject: Re: bug#15992: 'ls' ignores term capabilities when generating color. Date: Thu, 28 Nov 2013 16:35:32 -0500 User-Agent: KMail/1.13.7 (Linux/3.12.1; KDE/4.6.5; x86_64; ; ) References: <5297A80A.3090903@tlinx.org> In-Reply-To: <5297A80A.3090903@tlinx.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart15409766.VUSl8KpAJW"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201311281635.32898.vapier@gentoo.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit Cc: Linda Walsh , 15992@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.3 (----) --nextPart15409766.VUSl8KpAJW Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Thursday 28 November 2013 15:31:06 Linda Walsh wrote: > While I do have an alias that says: > alias ls='ls -CF --show-control-chars --color=always' there's your problem. don't use --color=always. -mike --nextPart15409766.VUSl8KpAJW Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJSl7ckAAoJEEFjO5/oN/WBjjMQANslIVyNAdwuG5tJ9v1A3JDF LpsL7OuakM2iQhJ0c4CXxAg95spK4wDPfiotwhnLosUeV/IbRR+X0hpfctMk0+hi z5F0cysjxKeITceV6v1fwVoc44ZSWW+Ec68CreL0F4uC4TyO0Hqdg/7FWPmTwncb +VVLc0nLMUHjNN0/fM++PHWdn8jcmUGQig3CElYZqXX7EW7gMZoDWqzFIc97rr7V NP7VRH8eoTLv0RCjkwzQAWAj6WIh6Qu4kMmlKUm9f7nYDjv9dKu/uoS/IDU2Rn4u 5w0J7jl9IujvxQ5xR1gDchG+RscN2z2PQMgC3ELeTweEvKgMhVGY7nBRUGWRO73D Bls9AYMxCowQkvaFClGClDKplcfCsqC9RaB7E/Nbfa6y7uS/FlTSTUjIQeHRRs+V rMDJPViGaRFz/ZCi6O8HleXG0MqfcMDSSW7RFUxfKaQkspxlDrioUwwRACI4pNEQ lOIxf620PqbLreklt85XQaiN0sP+xhNdcljMyLPVI0C8fxblQu358IfwJuBAqxvZ ZVkIcGtCp6JY24vZTI8xDkql44Kx9lLRkmC6AX/pzBUODf4wlpXX4n+xQaHXrgiV BX8aAM4BgJG/lUjCidCK3UOcax/dM2l8NR+PIgqtlvNF4uIZfmcHAdGVD3IyOK2f mZBzUtPBm0hanT6Dbho6 =HcEd -----END PGP SIGNATURE----- --nextPart15409766.VUSl8KpAJW-- From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 28 20:36:32 2013 Received: (at 15992) by debbugs.gnu.org; 29 Nov 2013 01:36:32 +0000 Received: from localhost ([127.0.0.1]:49429 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VmD0R-0002gx-FR for submit@debbugs.gnu.org; Thu, 28 Nov 2013 20:36:32 -0500 Received: from mail5.vodafone.ie ([213.233.128.176]:14410) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VmD0O-0002ga-HE for 15992@debbugs.gnu.org; Thu, 28 Nov 2013 20:36:29 -0500 Received: from unknown (HELO [192.168.1.79]) ([109.76.187.79]) by mail3.vodafone.ie with ESMTP; 29 Nov 2013 01:36:21 +0000 Message-ID: <5297EF95.2010505@draigBrady.com> Date: Fri, 29 Nov 2013 01:36:21 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#15992: 'ls' ignores term capabilities when generating color. References: <5297A80A.3090903@tlinx.org> In-Reply-To: <5297A80A.3090903@tlinx.org> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15992 Cc: 15992@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 11/28/2013 08:31 PM, Linda Walsh wrote: > I logged in on a *dumb* terminal > and did an 'ls'. Rather than a file list, I got: > > \x1b[00;32mwpad.dat\x1b[0m* > \x1b[00mwpad_socks.dat\x1b[0m > \x1b[00mwuredir.xml\x1b[0m > \x1b[00mx.c\x1b[0m > \x1b[00mx.c.orig\x1b[0m > \x1b[00;32mx1\x1b[0m* > \x1b[00mxaml\x1b[0m > \x1b[01;35mxmision-web\x1b[0m/ > \x1b[01;35mxrdp\x1b[0m/ > \x1b[00mxrdp-sesadmin.log\x1b[0m > \x1b[00;32mxtree117.zip\x1b[0m* > \x1b[00;32mxtree2b-20050606.zip\x1b[0m* > \x1b[01;35mxx\x1b[0m/ > \x1b[01;35mxxx\x1b[0m/ > \x1b[00;32myast2.txt\x1b[0m* > \x1b[40;33;01mzero\x1b[0m > \x1b[01;35mzips\x1b[0m/ > \x1b[01;35mztars\x1b[0m/ > \x1b[01;35mztest\x1b[0m/ > \x1b[00mzyppinst\x1b[0m > ------------------ > > While I do have an alias that says: > alias ls='ls -CF --show-control-chars --color=always' > > If the terminal HAS NO color capabilities, I would expect > it not to display anything where color was selected, > as the mapping for switching colors on a dumb terminal > is "". > > I tried settings for "TERM": > of "none", "dumb", and "" (empty) > > All gave the same strings as would be correct > for a 16-color terminal. > > IMO, "ls" shouldn't print out "bogus" strings for color > that are not in the listed "TERM"inal's capabilties. > > Wouldn't that be the wisest course of action? Or is > there a requirement, "poSomewhereIx" to print garbage strings > to terminals that don't have specific capabilities? > > ;-) So this is a fair point. I see the --color option as controlling color output based on whether output is a terminal or not. It would be beneficial to have more control to disable coloring if output is a terminal, but can't parse the color codes. Note that color handling for ls is split into dircolors to generate the static list of color values to use. ls itself doesn't query the $TERM. Now dircolors also works off a static list which it converts to the LS_COLORS env variable if it finds that the current $TERM is tagged in its config. So if dircolors doesn't find a matching $TERM it will output an empty LS_COLORS env variable. So far so good. However ls will default to its builtin ansi color config with a missing or empty LS_COLORS. It is debatable as to whether an empty LS_COLORS should disable colors completely, but I noticed that an invalid LS_COLORS will disable coloring, and output a warning. I.E. the following will not colorize the output: LS_COLORS='blah' ls --color=always That's at least inconsistent with an empty LS_COLORS not changing anything. So what we could do to in ls to address this is: if $LS_COLORS is unset or empty // dircolors not run or is having issues with this terminal if ($COLORTERM is set) or ($TERM = any in dircolors.h) # go with internal set else # disable coloring In that way the $TERM would be honored, but could be overridden with LS_COLORS. thanks, Pádraig. p.s. dircolors might honor $COLORTERM too, so that every $TERM in existence doesn't need to be added, though COLORTERM is not passed to remote ssh sessions like the TERM variable is for example. p.p.s a separate point that came to mind is that dircolors might support being passed a directory containing color configs to parse, which it continues doing until it finds one with a matching $TERM From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 16 09:51:10 2014 Received: (at 15992) by debbugs.gnu.org; 16 Apr 2014 13:51:10 +0000 Received: from localhost ([127.0.0.1]:49514 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WaQF4-0003JR-43 for submit@debbugs.gnu.org; Wed, 16 Apr 2014 09:51:10 -0400 Received: from mail-ob0-f178.google.com ([209.85.214.178]:46269) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WaQF0-0003Ip-Lg for 15992@debbugs.gnu.org; Wed, 16 Apr 2014 09:51:07 -0400 Received: by mail-ob0-f178.google.com with SMTP id wn1so788286obc.37 for <15992@debbugs.gnu.org>; Wed, 16 Apr 2014 06:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=akqPgR60ILPWMqR431uVi8IvloWf/ihbxhc/cuHE8iQ=; b=YtIfSe7QoIu6oGlRjTNbwm0xCrKVUCgPqXK1R9e3g84NmCAZkO8VYRydfjVQW7oYaq uaqzxB2dUYqQ7o8Sxklr0azpRoeDKPoS2iYM6m8GdoyJnDuf3JxftNT1hrFhKMUmhB+P mPY0ottzUmQ5OCM9w7w+03dZgGxxXKNdJDbtxqT/VkJbd5rR9+dhcKVNPryMbf1aXFTP vQURVWaJ3OhEAvL1wj29up1au5PZeWx5OoPO/6jON1VSOkcb05FVoUYC/mSiVl7uctf6 EEXmZJD8wYJdl5IjFuJSJF1yMEK0LMNqaSX3KpU394kWgG2RiA5uhkjOA8d3yJEv5P3A 2KyQ== MIME-Version: 1.0 X-Received: by 10.182.29.225 with SMTP id n1mr6854604obh.2.1397656260298; Wed, 16 Apr 2014 06:51:00 -0700 (PDT) Received: by 10.182.104.9 with HTTP; Wed, 16 Apr 2014 06:51:00 -0700 (PDT) Date: Wed, 16 Apr 2014 10:51:00 -0300 Message-ID: Subject: Re: bug#15992: 'ls' ignores term capabilities when generating color. From: Guilherme de Almeida Suckevicz To: 15992@debbugs.gnu.org Content-Type: multipart/alternative; boundary=001a11c2da9ce9cc1904f72934e0 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 15992 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --001a11c2da9ce9cc1904f72934e0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi P=C3=A1draig, I made a patch for this issue according to the tips above. I hope that is ok! [guilherme@almeida build]$ diff ../src/ls.c ../src/ls-orig.c 111d110 < #include "dircolors.h" 2330,2360d2328 < < /* GCC warning about pure attribute. */ < bool check_term_type (const char *) __attribute__ ((pure)); < < /* Check if the content of TERM is a valid name in dirname.h . */ < bool < know_term_type (void) < { < char const *line; < const char *term; < < term =3D getenv ("TERM"); < if (! term || ! *term) < return false; < < line =3D G_line; < while (line - G_line < sizeof (G_line)) < { < /* Get just lines begining with 'TERM '. */ < if (STRNCMP_LIT (line, "TERM ") =3D=3D 0) < { < if (STREQ (term, line + 5)) < return true; < } < < line +=3D strlen (line) + 1; < } < < return false; < } < 2370d2337 < 2372,2382c2339 < { < /* If COLORTERM is not set, check if the term type is know. */ < if (getenv ("COLORTERM") =3D=3D NULL) < { < if (! know_term_type ()) < { < print_with_color =3D false; < return; < } < } < } --- > return; Thank you very much for help me! :D Guilherme Almeida. --001a11c2da9ce9cc1904f72934e0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi P=C3=A1draig,

I made a patc= h for this issue according to the tips above.
I hope that is ok!

= [guilherme@almeida build]$ diff ../src/ls.c ../src/ls-orig.c
111d110< #include "dircolors.h"
2330,2360d2328
<
< /* GCC warning about pure attribute. */
= < bool check_term_type (const char *) __attribute__ ((pure));
< < /* Check if the content of TERM is a valid name in dirname.h . */ < bool
< know_term_type (void)
< {
<=C2=A0=C2=A0 char = const *line;
<=C2=A0=C2=A0 const char *term;
<
<=C2=A0= =C2=A0 term =3D getenv ("TERM");
<=C2=A0=C2=A0 if (! term |= | ! *term)
<=C2=A0=C2=A0=C2=A0=C2=A0 return false;
<
<=C2=A0=C2=A0 line =3D G_line;
<=C2=A0=C2=A0 while (line = - G_line < sizeof (G_line))
<=C2=A0=C2=A0=C2=A0=C2=A0 {
<=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Get just lines begining with 'TERM= '. */
<=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (STRNCMP_LIT (lin= e, "TERM ") =3D=3D 0)
< =C2=A0=C2=A0=C2=A0 {
< =C2=A0=C2=A0=C2=A0 =C2=A0 if (STREQ (term= , line + 5))
< =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return true;
= < =C2=A0=C2=A0=C2=A0 }
<
<=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 line +=3D strlen (line) + 1;
<=C2=A0=C2=A0=C2=A0=C2=A0 }
< =
<=C2=A0=C2=A0 return false;
< }
<
2370d2337
<
2372,2382c2339
<=C2=A0=C2=A0=C2=A0=C2=A0 {
<=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 /* If COLORTERM is not set, check if the term t= ype is know. */
<=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (getenv (&qu= ot;COLORTERM") =3D=3D NULL)
< =C2=A0=C2=A0=C2=A0 {
< =C2= =A0=C2=A0=C2=A0 =C2=A0 if (! know_term_type ())
< =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 {
< =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 print_with_color =3D false;
< =C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return;
< =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 }
< =C2=A0=C2=A0=C2=A0 }
<=C2=A0=C2=A0=C2= =A0=C2=A0 }
---
>=C2=A0=C2=A0=C2=A0=C2=A0 return;



<= /div>Thank you very much for help me! :D
Guilherme Almeida.
--001a11c2da9ce9cc1904f72934e0-- From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 16 11:56:12 2014 Received: (at 15992) by debbugs.gnu.org; 16 Apr 2014 15:56:12 +0000 Received: from localhost ([127.0.0.1]:49819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WaSC3-0006tr-EE for submit@debbugs.gnu.org; Wed, 16 Apr 2014 11:56:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65076) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WaSC0-0006ti-RX for 15992@debbugs.gnu.org; Wed, 16 Apr 2014 11:56:10 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3GFu7pp027484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Apr 2014 11:56:07 -0400 Received: from [10.36.116.96] (ovpn-116-96.ams2.redhat.com [10.36.116.96]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3GFu4wN020948 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 16 Apr 2014 11:56:06 -0400 Message-ID: <534EA814.9000205@draigBrady.com> Date: Wed, 16 Apr 2014 16:56:04 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Guilherme de Almeida Suckevicz Subject: Re: bug#15992: 'ls' ignores term capabilities when generating color. References: <5297A80A.3090903@tlinx.org> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------070403020609000506090603" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 15992 Cc: 15992@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This is a multi-part message in MIME format. --------------070403020609000506090603 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 04/16/2014 02:51 PM, Guilherme de Almeida Suckevicz wrote: > Hi Pádraig, > > I made a patch for this issue according to the tips above. > I hope that is ok! > > [guilherme@almeida build]$ diff ../src/ls.c ../src/ls-orig.c Note the patch is reversed, also we prefer unified format, also we'd much prefer a patch against the git repo. For general notes on supplying patches see: http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=blob;f=README-hacking;hb=HEAD > 2372,2382c2339 > < { > < /* If COLORTERM is not set, check if the term type is know. */ > < if (getenv ("COLORTERM") == NULL) > < { > < if (! know_term_type ()) > < { > < print_with_color = false; > < return; > < } > < } you want a return here too > < } I've cleaned up the patch and added a test. If you're Ok with it I'll push. thanks, Pádraig. --------------070403020609000506090603 Content-Type: text/x-patch; name="ls-dumb-term.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ls-dumb-term.patch" >From 3dbeb4e844889f25dcd0eff7a3b766bdcff560d8 Mon Sep 17 00:00:00 2001 From: Guilherme de Almeida Suckevicz Date: Wed, 16 Apr 2014 16:38:49 +0100 Subject: [PATCH] ls: don't output colors with unknown TERM env variable --colors controls whether to output colors depending on whether we're connected to a terminal or not, while this change gives control over which terminals we output colors to. * NEWS: Mention the change in behavior. * src/ls.c (known_term_type): A new function to search the static list from dircolors.h (parse_ls_colors): Honor the TERM when both LS_COLORS and COLORTERM are non empty. * tests/ls/color-term.sh: A new test. * tests/local.mk: Reference the new test. Fixes http://bugs.gnu.org/15992 --- NEWS | 6 ++++++ src/ls.c | 36 +++++++++++++++++++++++++++++++++++- tests/local.mk | 1 + tests/ls/color-term.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 1 deletions(-) create mode 100755 tests/ls/color-term.sh diff --git a/NEWS b/NEWS index 1d3ecf1..55f0b58 100644 --- a/NEWS +++ b/NEWS @@ -51,6 +51,12 @@ GNU coreutils NEWS -*- outline -*- od accepts a new option: --endian=TYPE to handle inputs with different byte orders, or to provide consistent output on systems with disparate endianness. +** Changes in behavior + + ls with none of LS_COLORS or COLORTERM environment variables set, + will now honor an empty or unknown TERM environment variable, + and not output colors even with --colors=always. + ** Improvements chroot has better --userspec and --group look-ups, with numeric IDs never diff --git a/src/ls.c b/src/ls.c index 5d87dd3..25e10fa 100644 --- a/src/ls.c +++ b/src/ls.c @@ -108,6 +108,7 @@ #include "xstrtol.h" #include "areadlink.h" #include "mbsalign.h" +#include "dircolors.h" /* Include last to avoid a clash of include guards with some premature versions of libcap. @@ -2326,6 +2327,30 @@ enum parse_state PS_FAIL }; + +/* Check if the content of TERM is a valid name in dircolors. */ + +static bool +known_term_type (void) +{ + char const *term = getenv ("TERM"); + if (! term || ! *term) + return false; + + char const *line = G_line; + while (line - G_line < sizeof (G_line)) + { + if (STRNCMP_LIT (line, "TERM ") == 0) + { + if (STREQ (term, line + 5)) + return true; + } + line += strlen (line) + 1; + } + + return false; +} + static void parse_ls_color (void) { @@ -2336,7 +2361,16 @@ parse_ls_color (void) struct color_ext_type *ext; /* Extension we are working on */ if ((p = getenv ("LS_COLORS")) == NULL || *p == '\0') - return; + { + /* LS_COLORS takes precedence, but if that's not set then + honor the COLORTERM and TERM env variables so that + we only go with the internal ANSI color codes if the + former is non empty or the latter is set to a known value. */ + char const *colorterm = getenv ("COLORTERM"); + if (! (colorterm && *colorterm) && ! known_term_type ()) + print_with_color = false; + return; + } ext = NULL; strcpy (label, "??"); diff --git a/tests/local.mk b/tests/local.mk index 26aef50..d58b603 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -537,6 +537,7 @@ all_tests = \ tests/ls/color-clear-to-eol.sh \ tests/ls/color-dtype-dir.sh \ tests/ls/color-norm.sh \ + tests/ls/color-term.sh \ tests/ls/dangle.sh \ tests/ls/dired.sh \ tests/ls/file-type.sh \ diff --git a/tests/ls/color-term.sh b/tests/ls/color-term.sh new file mode 100755 index 0000000..a8e0afa --- /dev/null +++ b/tests/ls/color-term.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Ensure "ls --color" doesn't output colors for TERM=dumb + +# Copyright (C) 2014 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ ls + +# Output time as something constant +export TIME_STYLE="+norm" + +touch exe || framework_failure_ +chmod u+x exe || framework_failure_ + +# output colors +LS_COLORS='' COLORTERM='nonempty' TERM='' ls --color=always exe >> out || fail=1 +LS_COLORS='' COLORTERM='' TERM='xterm' ls --color=always exe >> out || fail=1 + +# Don#t output colors +LS_COLORS='' COLORTERM='' TERM='dumb' ls --color=always exe >> out || fail=1 +LS_COLORS='' COLORTERM='' TERM='' ls --color=always exe >> out || fail=1 + +cat -A out > out.display || framework_failure_ +mv out.display out || framework_failure_ + +cat <<\EOF > exp || framework_failure_ +^[[0m^[[01;32mexe^[[0m$ +^[[0m^[[01;32mexe^[[0m$ +exe$ +exe$ +EOF + +compare exp out || fail=1 + +Exit $fail -- 1.7.7.6 --------------070403020609000506090603-- From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 16 14:21:39 2014 Received: (at 15992) by debbugs.gnu.org; 16 Apr 2014 18:21:39 +0000 Received: from localhost ([127.0.0.1]:49901 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WaUSn-0004sr-UY for submit@debbugs.gnu.org; Wed, 16 Apr 2014 14:21:38 -0400 Received: from moutng.kundenserver.de ([212.227.126.130]:63348) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WaUSl-0004sQ-1e for 15992@debbugs.gnu.org; Wed, 16 Apr 2014 14:21:35 -0400 Received: from [192.168.1.20] (p548E555D.dip0.t-ipconnect.de [84.142.85.93]) by mrelayeu.kundenserver.de (node=mreue006) with ESMTP (Nemesis) id 0MWLVt-1WU8ob0QTB-00XIvB; Wed, 16 Apr 2014 20:21:28 +0200 Message-ID: <534ECA27.50808@bernhard-voelker.de> Date: Wed, 16 Apr 2014 20:21:27 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , Guilherme de Almeida Suckevicz Subject: Re: bug#15992: 'ls' ignores term capabilities when generating color. References: <5297A80A.3090903@tlinx.org> <534EA814.9000205@draigBrady.com> In-Reply-To: <534EA814.9000205@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:A07R416aXTbgJ4eZdWL+uxPJapvflxC8rELbvyeiPkm MAVwddQ5ZiL09Zqc51vCqbhi0qF/M4uOsLEP3uISvD+JQZN5+s XnEXX1+nDmahAIgF1uCw74OB2aLMZnzlDiqEs+e7mBT2A8llt2 04uH+vC2InpVt5vPJaequeAfJDr2aIbjtYcnbAUrXy7+j67+z2 d1or+wzcU75QjMUbSo3NBkQmB7VSrS06Jss9jaNm/S/KF/4g1m uVhiavPffboBYgGaoyd73wlERvaGatWNJ9h4DjJoDWnCG6vlpf ps5b0/foZ0eXM6sXIok57klkU9knJaCoR3BpsRR50PWYcs5qQS 4HMfMKU3Nhn5ZuSgNQgEjZdaUeJh6fQPR9wwt3g0p X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15992 Cc: 15992@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 04/16/2014 05:56 PM, Pádraig Brady wrote: > I've cleaned up the patch and added a test. > If you're Ok with it I'll push. Minor nit: > +++ b/tests/ls/color-term.sh > [...] > +# Don#t output colors s/Don#t/Don't/ Otherwise +1. Thanks & have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 16 21:14:37 2014 Received: (at 15992-done) by debbugs.gnu.org; 17 Apr 2014 01:14:37 +0000 Received: from localhost ([127.0.0.1]:50061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WaauT-00083L-0d for submit@debbugs.gnu.org; Wed, 16 Apr 2014 21:14:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63431) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WaauQ-00083A-AQ for 15992-done@debbugs.gnu.org; Wed, 16 Apr 2014 21:14:35 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3H1EVp8000855 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Apr 2014 21:14:31 -0400 Received: from [10.36.116.96] (ovpn-116-96.ams2.redhat.com [10.36.116.96]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3H1ESQM030021 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 16 Apr 2014 21:14:30 -0400 Message-ID: <534F2AF4.5060405@draigBrady.com> Date: Thu, 17 Apr 2014 02:14:28 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#15992: 'ls' ignores term capabilities when generating color. References: <5297A80A.3090903@tlinx.org> <534EA814.9000205@draigBrady.com> <534ECA27.50808@bernhard-voelker.de> In-Reply-To: <534ECA27.50808@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 15992-done Cc: Guilherme de Almeida Suckevicz , 15992-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) On 04/16/2014 07:21 PM, Bernhard Voelker wrote: > On 04/16/2014 05:56 PM, Pádraig Brady wrote: >> I've cleaned up the patch and added a test. >> If you're Ok with it I'll push. > > Minor nit: > >> +++ b/tests/ls/color-term.sh >> [...] >> +# Don#t output colors > > s/Don#t/Don't/ > > Otherwise +1. > > Thanks & have a nice day, > Berny > Guilherme confirmed privately that adjustments are OK, so pushing now. thanks for the review, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 18 06:28:28 2014 Received: (at 15992) by debbugs.gnu.org; 18 Apr 2014 10:28:28 +0000 Received: from localhost ([127.0.0.1]:51571 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wb61z-0001zO-BD for submit@debbugs.gnu.org; Fri, 18 Apr 2014 06:28:27 -0400 Received: from mail5.vodafone.ie ([213.233.128.176]:28796) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wb61w-0001z5-4b for 15992@debbugs.gnu.org; Fri, 18 Apr 2014 06:28:25 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApwBAMb9UFNtTcUh/2dsb2JhbAANTYNVg2mFXbsCgTODGQEBAQQjZgsNBAMBAgEJFgsCAgkDAgECAT0IBwwGAgEBiEIIqCN2oysXjlEYgm+BSQSQbIE3iAKFSY8B Received: from unknown (HELO [192.168.1.79]) ([109.77.197.33]) by mail3.vodafone.ie with ESMTP; 18 Apr 2014 11:28:17 +0100 Message-ID: <5350FE40.2060400@draigBrady.com> Date: Fri, 18 Apr 2014 11:28:16 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 15992@debbugs.gnu.org, coreutils@tlinx.org Subject: Re: bug#15992: 'ls' ignores term capabilities when generating color. References: <5297A80A.3090903@tlinx.org> <534EA814.9000205@draigBrady.com> <534ECA27.50808@bernhard-voelker.de> <534F2AF4.5060405@draigBrady.com> In-Reply-To: <534F2AF4.5060405@draigBrady.com> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------000200070009030003050503" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15992 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------000200070009030003050503 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 04/17/2014 02:14 AM, Pádraig Brady wrote: > On 04/16/2014 07:21 PM, Bernhard Voelker wrote: >> On 04/16/2014 05:56 PM, Pádraig Brady wrote: >>> I've cleaned up the patch and added a test. >>> If you're Ok with it I'll push. >> >> Minor nit: >> >>> +++ b/tests/ls/color-term.sh >>> [...] >>> +# Don#t output colors >> >> s/Don#t/Don't/ >> >> Otherwise +1. >> >> Thanks & have a nice day, >> Berny >> > Guilherme confirmed privately that adjustments are OK, > so pushing now. I pushed this follow up to avoid test failures (since tests were dependent on the COLORTERM being set in the environment). thanks, Pádraig. --------------000200070009030003050503 Content-Type: text/x-patch; name="ls-colorterm.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ls-colorterm.patch" >From 14613e2fd132a1e252849cd881706bca8428f9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Fri, 18 Apr 2014 11:19:10 +0100 Subject: [PATCH] tests: make ls tests independent of COLORTERM env Since the recent commit v8.22-68-g08783f1, ls coloring is now dependent on the COLORTERM environment variable. * tests/envvar-check: Unset COLORTERM from test environment. * tests/ls/color-dtype-dir.sh: Ensure coloring is used. * tests/misc/ls-misc.pl: Likewise. Prompted by the continuous integration build failure at: http://hydra.nixos.org/build/10397646 --- tests/envvar-check | 1 + tests/ls/color-dtype-dir.sh | 2 +- tests/misc/ls-misc.pl | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/envvar-check b/tests/envvar-check index 09b4ded..b6d94b4 100644 --- a/tests/envvar-check +++ b/tests/envvar-check @@ -43,6 +43,7 @@ vars=' SIMPLE_BACKUP_SUFFIX TABSIZE TERM + COLORTERM TIME_STYLE TMPDIR VERSION_CONTROL diff --git a/tests/ls/color-dtype-dir.sh b/tests/ls/color-dtype-dir.sh index 88dd781..559a188 100755 --- a/tests/ls/color-dtype-dir.sh +++ b/tests/ls/color-dtype-dir.sh @@ -30,7 +30,7 @@ chmod o+w other-writable || framework_failure_ chmod o+t sticky || framework_failure_ -ls --color=always > out || fail=1 +TERM=xterm ls --color=always > out || fail=1 cat -A out > o1 || fail=1 mv o1 out || fail=1 diff --git a/tests/misc/ls-misc.pl b/tests/misc/ls-misc.pl index f562b72..a47e70b 100755 --- a/tests/misc/ls-misc.pl +++ b/tests/misc/ls-misc.pl @@ -303,9 +303,12 @@ my @Tests = . "\e[37;44msticky$e\n" }, + {PRE => sub { + push_ls_colors('ow=34;42:tw=30;42:sg=30;43:su=37;41:st=37;44'); }}, {POST => sub { unlink qw(setuid setgid); - foreach my $dir (qw(owr owt sticky)) {rmdir $dir} }}, + foreach my $dir (qw(owr owt sticky)) {rmdir $dir} + restore_ls_colors; }}, ], # For 5.97 and earlier, --file-type acted like --indicator-style=slash. -- 1.7.7.6 --------------000200070009030003050503-- From unknown Sat Aug 16 16:08:59 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 16 May 2014 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator