On Thu, Jul 20, 2023 at 01:11:10PM -0400, Ionen Wolkens wrote:
> On Thu, Jul 20, 2023 at 06:58:04PM +0200, Ulrich Mueller wrote:
> > >>>>> On Thu, 20 Jul 2023, Mike Gilbert wrote:
> > 
> > > On Thu, Jul 20, 2023 at 11:06 AM Florian Schmaus <f...@gentoo.org> wrote:
> > >> While the bash language has no boolean datatype, you can exploit the
> > >> fact that 'true' and 'false' are usually shell builtins:
> > >> 
> > >> : "${MESON_VERBOSE:=true}"
> > >> 
> > >> and then later
> > >> 
> > >> if $MESON_VERBOSE; then
> > >> mesoncompileargs+=( --verbose )
> > >> fi
> > 
> > > I think we generally try to avoid exploiting that behavior in ebuilds.
> > > It's usually much more obvious to check for a non-empty string, or for
> > > a specific value.
> > 
> > Testing for a non-empty variable is also faster than executing "true"
> > or "false" builtins from variable values. (Which doesn't play any role
> > here, but readability of the code does.)
> 
> Yes, this is what I'd recommend typically. Then documentation can say
> "if set to a non-empty value" to toggle.
...ultimately I feel these should be e.g. MESON_NO_VERBOSE, and be
default unset (same for the others build systems).

Alternatively could also consider a unified SOMETHING_NO_VERBOSE
variable that would be used by all eclasses / ebuild where possible
or relevant.

> 
> Unfortunately this doesn't work so great when the default is enabled.
> Telling people to empty it is probably weird.
> 
> wrt true/false, given MESON_VERBOSE can be set "by users" to anything
> I think trying to execute that would be extra weird.
> 
> On a side-note, another way to avoid case statements is extglob which
> is always enabled in [[ ]] (no need for shopt)

s/another/a/, just meant this as a side-tidbit that doesn't use
full on regex (unrelated)

> 
> aka: [[ ${var} == @(first|second|third) ]]

-- 
ionen

Attachment: signature.asc
Description: PGP signature

Reply via email to