From 3a48f36d43dd42da9b450edfc324e91eecd3a79d Mon Sep 17 00:00:00 2001 From: fbt Date: Sat, 23 Nov 2019 09:57:58 +0300 Subject: [PATCH] Use jq Signed-off-by: fbt --- ufw | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ufw b/ufw index 11283be..f390b89 100755 --- a/ufw +++ b/ufw @@ -82,7 +82,7 @@ get_album_id() { get_api_status <<< "$api_response" if (( api_status == 200 )); then - album_id=$( jshon -e data -e album -e id -u <<< "$api_response" ) + album_id=$( jq -r '.data.album.id' <<< "$api_response" ) misc_curl_args+=( -F album_id="$album_id" ) else printf 'Error [album]: %s %s\n' "$api_status" "$api_status_message" @@ -162,7 +162,7 @@ upload() { get_api_status <<< "$api_response" if (( api_status == 200 )); then - file_link=$( jshon -e data -e "$file_url_request" -u <<< "$api_response" ) + file_link=$( jq -r ".data.${file_url_request}" <<< "$api_response" ) (( flag_shortlink )) || { (( flag_directlink )) || file_link="${file_link#*.}" @@ -188,7 +188,7 @@ get_shortlink() { if (( api_status == 200 )); then read -r short_url real_url < <( - jshon -e data -e short_url -u <<< "$api_response" + jq -r '.data.short_url' <<< "$api_response" ) printf '%s\n' "$short_url" @@ -221,7 +221,7 @@ take_screenshot() { get_api_status() { read -d '' -r api_status api_status_message < <( - jshon -e status -e code -u -p -e message -u + jq -r '.status.code, .status.message' ) if ! (( api_status == 200 )); then @@ -252,7 +252,7 @@ get_my_ip() { get_api_status <<< "$api_response" if (( api_status == 200 )); then - my_ip=$( jshon -e data -e ip -u <<< "$api_response" ) + my_ip=$( jq -r '.data.ip' <<< "$api_response" ) printf '%s\n' "$my_ip" else printf 'Error: %s %s\n' "$api_status" "$api_status_message"