let's add a new helper named "usex". example implementation: usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } spec being: usex <USE flag> [true output] [false output] [true suffix] [false suffix] if any output options are omitted (an empty string does not count as omission, hence "${var-foo}" and not "${var:-foo}", they'll default to the USE flag the suffix options get appended to the related output if they're specified while the output/suffix options could be merged so that usex only takes 3 arguments, it limits the caller a little bit. the extended args allow for tricks like: usex foo --with{,out}-option =fast where as a combined arg approach would force callers to be more verbose: usex foo --with-option=fast --without-option and for the people who prefer to be more verbose, the latter form works even when usex accepts 5 args instead of 3
> the extended args allow for tricks like: > usex foo --with{,out}-option =fast Can you imagine a frequent usage case where the suffix isn't prefixed by an = sign? If not, the following would make the behaviour more consistent with what we have in use_with() and use_enable(): usex() { use "$1" && echo "${2-yes}${4+=$4}" || echo "${3-no}${5+=$5}" ; } Your above example would become: usex foo --with{,out}-option fast
(In reply to comment #1) > > the extended args allow for tricks like: > > usex foo --with{,out}-option =fast > > Can you imagine a frequent usage case where the suffix isn't prefixed by an = > sign? If not, the following would make the behaviour more consistent with what > we have in use_with() and use_enable(): > > usex() { use "$1" && echo "${2-yes}${4+=$4}" || echo "${3-no}${5+=$5}" ; } > > Your above example would become: > usex foo --with{,out}-option fast Why not just 'usex foo --with{,out}-option=fast' with = adding handled explicitly by caller?
i'd rather not encode syntax decisions into the helper. i assume i cant foresee all the possibilities. and the overhead on the caller is minuscule.
> usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } This returns always true. Is this what we want? Maybe it would be more natural to return the status of the "use" call.
(In reply to comment #4) > > usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } > > This returns always true. Is this what we want? Hm, use_with and use_enable do the same. So I guess this is o.k.
PMS commit: http://git.overlays.gentoo.org/gitweb/?p=proj/pms.git;a=commit;h=91a920caaf45dee42dc1513c8853b0fd43f6a167