From owner-svn-src-head@freebsd.org Thu May 21 14:39:01 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 70A292DAD32; Thu, 21 May 2020 14:39:01 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49SXLY2LG0z3bDy; Thu, 21 May 2020 14:39:01 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4B766ED36; Thu, 21 May 2020 14:39:01 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04LEd1TK038266; Thu, 21 May 2020 14:39:01 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04LEd0G0038264; Thu, 21 May 2020 14:39:00 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202005211439.04LEd0G0038264@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 21 May 2020 14:39:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361331 - head/bin/ls X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/bin/ls X-SVN-Commit-Revision: 361331 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2020 14:39:01 -0000 Author: kevans Date: Thu May 21 14:39:00 2020 New Revision: 361331 URL: https://svnweb.freebsd.org/changeset/base/361331 Log: ls(1): actually restore proper behavior Highlights: - CLICOLOR in the environment should imply --color=auto to maintain compatibility with historical behavior - -G should set CLICOLOR and imply --color=auto The manpage has been updated to draw the connection between -G and --color; the former is in-fact a sort of compromise between --color=always and --color=auto, where we'll output color regardless of the environment lacking CLICOLOR/COLORTERM assuming stdout is a tty. X-MFC-With: r361318 Modified: head/bin/ls/ls.1 head/bin/ls/ls.c Modified: head/bin/ls/ls.1 ============================================================================== --- head/bin/ls/ls.1 Thu May 21 13:46:30 2020 (r361330) +++ head/bin/ls/ls.1 Thu May 21 14:39:00 2020 (r361331) @@ -32,7 +32,7 @@ .\" @(#)ls.1 8.7 (Berkeley) 7/29/94 .\" $FreeBSD$ .\" -.Dd May 20, 2020 +.Dd May 21, 2020 .Dt LS 1 .Os .Sh NAME @@ -135,7 +135,8 @@ This option is equivalent to defining .Ev CLICOLOR or .Ev COLORTERM -in the environment. +in the environment and setting +.Fl -color Ns = Ns Ar auto . (See below.) This functionality can be compiled out by removing the definition of .Ev COLORLS . Modified: head/bin/ls/ls.c ============================================================================== --- head/bin/ls/ls.c Thu May 21 13:46:30 2020 (r361330) +++ head/bin/ls/ls.c Thu May 21 14:39:00 2020 (r361331) @@ -265,6 +265,13 @@ main(int argc, char *argv[]) fts_options = FTS_PHYSICAL; if (getenv("LS_SAMESORT")) f_samesort = 1; + + /* + * For historical compatibility, we'll use our autodetection if CLICOLOR + * is set. + */ + if (getenv("CLICOLOR")) + colorflag = COLORFLAG_AUTO; while ((ch = getopt_long(argc, argv, "+1ABCD:FGHILPRSTUWXZabcdfghiklmnopqrstuwxy,", long_opts, NULL)) != -1) { @@ -342,7 +349,13 @@ main(int argc, char *argv[]) f_slash = 0; break; case 'G': + /* + * We both set CLICOLOR here and set colorflag to + * COLORFLAG_AUTO, because -G should not force color if + * stdout isn't a tty. + */ setenv("CLICOLOR", "", 1); + colorflag = COLORFLAG_AUTO; break; case 'H': fts_options |= FTS_COMFOLLOW;