From d1becc7836bd145b8ae70a009424232120872163 Mon Sep 17 00:00:00 2001 From: fbt Date: Tue, 3 Feb 2015 12:58:00 +0300 Subject: [PATCH] Show versions in AUR searches, less jshon calls, read -r --- zpac | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/zpac b/zpac index e888d95..da95c2c 100755 --- a/zpac +++ b/zpac @@ -35,7 +35,14 @@ aur.search() { aur_search_results=( $( jshon -e results -a -e Name -u <<< "$aur_api_search_data" ) ) for i in "${!aur_search_results[@]}"; do - printf 'aur/%s\n %s\n' "${aur_search_results[${i}]}" "$( jshon -e results -e $i -e Description -u <<< "$aur_api_search_data" )" + { + read -r version + read -r description + } < <( + jshon -e results -e $i -e Version -u -p -e Description -u <<< "$aur_api_search_data" + ) + + printf '%s %s\n %s\n' "aur/${aur_search_results[$i]}" "$version" "$description" done else return 1 @@ -56,10 +63,14 @@ aur.info() { aur.get() { local dep_name aur_api_multireq aur_deps_api_data aur_deps_count aur_deps pkg_aur_info pkg_base tarball_path - read pkg_aur_info + read -r pkg_aur_info - pkg_base=$( jshon -e results -e PackageBase -u <<< "$pkg_aur_info" ) - tarball_path=$( jshon -e results -e URLPath -u <<< "$pkg_aur_info" ) + { + read -r pkg_base + read -r tarball_path + } < <( + jshon -e results -e PackageBase -u -p -e URLPath -u <<< "$pkg_aur_info" + ) cd "$cfg_workdir" @@ -120,7 +131,7 @@ args_norm() { --) printf '%s\n' '--'; break;; --*) - IFS='=' read arg opt <<< "$1" + IFS='=' read -r arg opt <<< "$1" printf '%s\n' "$arg" [[ "$opt" ]] && { @@ -129,7 +140,7 @@ args_norm() { ;; -*) - while read -n1 c + while read -r -n1 c do case "$c" in -|'') :;; @@ -213,7 +224,7 @@ main() { if (( ! "$?" )); then repo='aur' else - while read; do + while read -r; do if [[ "$REPLY" =~ ^Repository ]]; then repo="${REPLY##* }" fi