Script gentoo use flags

From Alessandro's Wiki

In Gentoo Linux portage, USE flags are words representing parts of software that can be compiled with or without those "pieces"

script uses

it's a tiny dirty bash script very useful to know the meaning of a use flag (and check his existance) from terminal


#!/bin/bash
# by porcelinux
source /etc/make.conf
USEfiles="/usr/portage/profiles/use.desc /usr/portage/profiles/use.local.desc"
if ! [ "x$1" == "x" ]
then
        USES="$1"
else
        USES=$USE
fi

# to store the cleaned uses 
 newuses=""
for thisusefile in $USEfiles
do
echo "according: `basename $thisusefile` 
..."
        for thisuse in $USES
        do
                desc=""
                ABSflag=`echo $thisuse|sed -e s/-//`
                # echo ">> Use Flag [ $a ] " 
                if ( `grep -q ^$ABSflag $thisusefile` )
                then
                        [ "$ABSflag" == "$thisuse"  ] || desc="NOT> "
                        desc="$desc "`grep "^$ABSflag" $thisusefile`
                        newuses="$newuses $thisuse"
                else
                        desc="!$ABSflag --> Use flag NOT FOUND !"
                fi
                echo $desc

        done
echo "newuses:  $newuses"
done