1 |
>>>>> On Tue, 13 Sep 2011, Mike Frysinger wrote: |
2 |
|
3 |
> On Tuesday, September 13, 2011 19:08:09 Brian Harring wrote: |
4 |
>> Making it overridable seems wiser- |
5 |
>> |
6 |
>> usex() { |
7 |
>> local flag="$1" |
8 |
>> local tval=${2-yes} |
9 |
>> local fval=${3-no} |
10 |
>> if use $flag; then |
11 |
>> echo "${tval}" |
12 |
>> else |
13 |
>> echo "${fval}" |
14 |
>> fi |
15 |
>> } |
16 |
|
17 |
Looks verbose. ;-) |
18 |
|
19 |
> i dont get it. mine already does exactly this, just in one line. |
20 |
> usex() { use $1 && echo ${2:-yes} || echo ${3:-no} ; } |
21 |
|
22 |
You should omit the colons though. ${2-yes} and ${3-no} will allow for |
23 |
an explicit empty string as argument, whereas the :- variants won't. |
24 |
|
25 |
Also quotes around the echo arguments can't harm. |
26 |
|
27 |
Ulrich |