diff options
author | Tim Harder <radhermit@gmail.com> | 2015-11-28 02:19:56 -0500 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2015-11-28 02:19:56 -0500 |
commit | 8ce2b9ab0596d9f309567ce98b4eed2459203655 (patch) | |
tree | 160fe0de8d66011691198058e414bc74c8d97329 /shell | |
parent | shell/pkgcore.sh: various changes to fix usage with bash (diff) | |
download | pkgcore-8ce2b9ab0596d9f309567ce98b4eed2459203655.tar.gz pkgcore-8ce2b9ab0596d9f309567ce98b4eed2459203655.tar.bz2 pkgcore-8ce2b9ab0596d9f309567ce98b4eed2459203655.zip |
shell/pkgcore.sh: clean up checking for bad package atoms
Diffstat (limited to 'shell')
-rw-r--r-- | shell/pkgcore.sh | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/shell/pkgcore.sh b/shell/pkgcore.sh index e388fa62..919a2a0a 100644 --- a/shell/pkgcore.sh +++ b/shell/pkgcore.sh @@ -5,21 +5,23 @@ # basically required. _ebuild_path() { - if [[ -z $1 || ${1:0:1} == "-" ]]; then + if [[ -z $1 ]]; then echo "Enter a valid package name." >&2 return 1 fi - repo=$2 local -a pkg - local p + local p repo=$2 if [[ -n ${repo} ]]; then - pkg=( $(pquery -r "${repo}" --raw "$1" --cpv --one-attr path -n) ) + pkg=( $(pquery -r "${repo}" --raw --cpv --one-attr path -n -- "$1" 2>/dev/null) ) else - pkg=( $(pquery --ebuild-repos --raw "$1" --cpv --one-attr path -n) ) + pkg=( $(pquery --ebuild-repos --raw --cpv --one-attr path -n -- "$1" 2>/dev/null) ) + fi + if [[ $? != 0 ]]; then + echo "Invalid package atom: '$1'" >&2 + return 1 fi - [[ $? != 0 ]] && return 1 if [[ -z ${pkg[@]} ]]; then echo "No matches found." >&2 |