Use one jshon call for search results

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Alad Wenter 2016-03-17 02:25:32 +03:00 committed by fbt
parent aacf420a68
commit 96b7584153

17
prm
View File

@ -32,7 +32,7 @@ usage() {
} }
aur.search() { aur.search() {
declare i aur_api_search_data aur_search_result_num aur_search_results version description declare i aur_api_search_data aur_search_result_num version description
aur_api_search_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}&type=search&arg=${1}" ) aur_api_search_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}&type=search&arg=${1}" )
aur_search_result_num=$( jshon -e resultcount -u <<< "$aur_api_search_data" ) aur_search_result_num=$( jshon -e resultcount -u <<< "$aur_api_search_data" )
@ -40,18 +40,13 @@ aur.search() {
# Exit if nothing was found # Exit if nothing was found
(( aur_search_result_num )) || { return 1; } (( aur_search_result_num )) || { return 1; }
aur_search_results=( $( jshon -e results -a -e Name -u <<< "$aur_api_search_data" ) ) while {
read -r name
for i in "${!aur_search_results[@]}"; do
{
read -r version read -r version
read -r description read -r description
} < <( } do
jshon -e results -e $i -e Version -u -p -e Description -u <<< "$aur_api_search_data" printf '%s %s\n %s\n' "aur/$name" "$version" "$description"
) done < <( jshon -C -e results -a -e Name -u -p -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
} }
aur.info() { aur.info() {