USE Flag Conditional Code

Often a particular block of code must only be executed if a given USE flag is set (or unset). For large blocks, if use foo is best, or for inverse tests either if ! use foo or if use !foo can be used (the former is more common and is recommended for readability). For single-statement conditions, the use foo && blah (or use foo || blah for negatives) form is often more readable.

The if [ "`use foo`" ] and if [ -n "`use foo`" ] forms which are occasionally seen in older code must not be used.

die will not work as expected within a subshell, so code in the form use foo && ( blah ; blah ) should be avoided in favour of a proper if statement. See . # USE conditional blocks... if use livecd ; then # remove some extra files for a small livecd install rm -fr ${vimfiles}/{compiler,doc,ftplugin,indent} fi # Inverse USE conditional blocks... if ! use cscope ; then # the --disable-cscope configure arg doesn't quite work properly, # so sed it out of feature.h if we're not USEing cscope. sed -i -e '/# define FEAT_CSCOPE/d' src/feature.h || die "couldn't disable cscope" fi # USE conditional statements... use ssl && epatch ${FILESDIR}/${P}-ssl.patch use sparc && filter-flags -fomit-frame-pointer # Inverse USE conditional statements... use ncurses || epatch ${FILESDIR}/${P}-no-ncurses.patch

For echoing content based upon a USE flag, there is often a better helper function available.

You must not rely upon use producing an output this no longer happens. If you really need output displayed, use the usev function. The useq function is available for explicitly requesting no output.