Date: Wed, 18 Aug 2021 18:46:53 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 257886] ls: don't check color env variables if compiled with WITHOUT_LS_COLORS="YES" Message-ID: <bug-257886-227-Df48a83TUY@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-257886-227@https.bugs.freebsd.org/bugzilla/> References: <bug-257886-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D257886 Piotr Pawel Stefaniak <pstef@freebsd.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pstef@freebsd.org --- Comment #2 from Piotr Pawel Stefaniak <pstef@freebsd.org> --- Hi, I agree with you, but I would fix this another way: since the warnx is generally useless, I would like to remove it. But Ed pointed out that we may want to have a way to determine whether a particular copy of ls has been compiled with color support or not. So I think it's best to move the warnx = to getopt in a WITHOUT_LS_COLORS build to fire if user asks for color. Like th= is: diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 338b3d1d2a2..92575711251 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[] =3D { -#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 =3D 1; break; -#ifdef COLORLS case COLOR_OPT: +#ifdef COLORLS if (optarg =3D=3D NULL || do_color_always(optarg)) colorflag =3D COLORFLAG_ALWAYS; else if (do_color_auto(optarg)) @@ -460,6 +458,8 @@ main(int argc, char *argv[]) errx(2, "unsupported --color value '%s' (mu= st 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 =3D 1; explicitansi =3D true; } -#else - warnx("color support not compiled in"); #endif /*COLORLS*/ } --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-257886-227-Df48a83TUY>