>>>>> 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

Reply via email to