From owner-dev-commits-src-main@freebsd.org Thu Aug 19 19:24:06 2021 Return-Path: Delivered-To: dev-commits-src-main@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 7FC4166A8B8; Thu, 19 Aug 2021 19:24:06 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GrF7V39X2z3jwy; Thu, 19 Aug 2021 19:24:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5633F3317; Thu, 19 Aug 2021 19:24:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17JJO6cW078700; Thu, 19 Aug 2021 19:24:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17JJO6WD078699; Thu, 19 Aug 2021 19:24:06 GMT (envelope-from git) Date: Thu, 19 Aug 2021 19:24:06 GMT Message-Id: <202108191924.17JJO6WD078699@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: ced2dcadccfc - main - ls: prevent no-color build from complaining when COLORTERM is non-empty MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ced2dcadccfcff8f7991b3cb5f6f70d6710eadfb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Aug 2021 19:24:06 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=ced2dcadccfcff8f7991b3cb5f6f70d6710eadfb commit ced2dcadccfcff8f7991b3cb5f6f70d6710eadfb Author: Piotr Pawel Stefaniak AuthorDate: 2021-08-18 20:47:37 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-08-19 19:22:16 +0000 ls: prevent no-color build from complaining when COLORTERM is non-empty As 257886 reports, if ls(1) is built with WITHOUT_LS_COLORS="YES", it issues a warning whenever COLORTERM is non-empty. The warning is not useful, so I thought to remove it, but as Ed pointed out, we may want to have a way to determine whether a particular copy of ls has been compiled with color support or not. Therefore move the warnx() call to the getopt loop in a WITHOUT_LS_COLORS build to fire when the user asks for colored output. PR: 257886 Reported by: Marko Turk Reviewed by: kevans --- bin/ls/ls.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 338b3d1d2a26..92575711251d 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -105,9 +105,7 @@ static void traverse(int, char **, int); static const struct option long_opts[] = { -#ifdef COLORLS {"color", optional_argument, NULL, COLOR_OPT}, -#endif {NULL, no_argument, NULL, 0} }; @@ -448,8 +446,8 @@ main(int argc, char *argv[]) case 'y': f_samesort = 1; break; -#ifdef COLORLS case COLOR_OPT: +#ifdef COLORLS if (optarg == NULL || do_color_always(optarg)) colorflag = COLORFLAG_ALWAYS; else if (do_color_auto(optarg)) @@ -460,6 +458,8 @@ main(int argc, char *argv[]) errx(2, "unsupported --color value '%s' (must be always, auto, or never)", optarg); break; +#else + warnx("color support not compiled in"); #endif default: case '?': @@ -503,8 +503,6 @@ main(int argc, char *argv[]) f_color = 1; explicitansi = true; } -#else - warnx("color support not compiled in"); #endif /*COLORLS*/ }