#!/bin/bash # # ewww 0.4 # author: Christian Birchinger # # Version for portage >=2.1 cache format # WEBBROWSER='browser' #PORTDIR="`portageq portdir`" PORTDIR='/usr/portage' if [ -z "$1" ]; then echo -e "\nUsage: ${0##*/} [category/]application\n" exit fi string="$1" if [[ "${string}" = */* ]]; then cachefile="/var/cache/edb/dep/${PORTDIR}/$(portageq best_visible / ${string})" if [ ! -f "${cachefile}" ]; then echo "No matches found." exit fi homepage="`grep '^HOMEPAGE=' ${cachefile} | cut -f2- -d=`" exec ${WEBBROWSER} "${homepage}" exit fi counter=0 emerge --nospinner -s ${string} | ( while read output; do if [ "${output:0:3}" = "* " ]; then let counter++ hits="${output##*\ } ${hits}" fi if [ "${output:0:9}" = "Homepage:" ]; then lasthp=${homepage} homepage="${output##*\ }" [ "${homepage}" = "${lasthp}" ] && let counter-- fi done if [ ${counter} = 0 ]; then echo "No matches found." elif [ ${counter} = 1 ]; then exec ${WEBBROWSER} ${homepage} else echo "Multiple matches found: ${hits}" echo "Be more specific." fi )