Gentoo Archives: gentoo-dev

From: Ulrich Mueller <ulm@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] new `usex` helper
Date: Wed, 14 Sep 2011 06:03:15
Message-Id: 20080.17269.880034.374347@a1i15.kph.uni-mainz.de
In Reply to: Re: [gentoo-dev] new `usex` helper by Mike Frysinger
>>>>> On Tue, 13 Sep 2011, Mike Frysinger wrote:
> On Tuesday, September 13, 2011 19:08:09 Brian Harring wrote: >> Making it overridable seems wiser- >> >> usex() { >> local flag="$1" >> local tval=${2-yes} >> local fval=${3-no} >> if use $flag; then >> echo "${tval}" >> else >> echo "${fval}" >> fi >> }
Looks verbose. ;-)
> i dont get it. mine already does exactly this, just in one line. > usex() { use $1 && echo ${2:-yes} || echo ${3:-no} ; }
You should omit the colons though. ${2-yes} and ${3-no} will allow for an explicit empty string as argument, whereas the :- variants won't. Also quotes around the echo arguments can't harm. Ulrich

Replies

Subject Author
Re: [gentoo-dev] new `usex` helper Mike Frysinger <vapier@g.o>