I'm trying to write a bash function which checks if a package is installed and installs it if needed. Right now it always installs regardless.
install() { echo "checking if $1 is already installed" if [[ ! $(equery -q l $1 | grep -q "$1") ]] then emerge -v $1 else echo "$1 is already installed" fi } install "oracle-jdk-bin" - the output of
equery -q l $1isdev-java/oracle-jdk-bin-1.8.0.45 - grep should find oracle-jdk-bin and return 1