Skip to content

Commit 60eb98d

Browse files
committed
Safer quoting
1 parent 42d82b9 commit 60eb98d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

chatgpt.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ EOF
5454
# $1 should be the response body
5555
handle_error() {
5656
if echo "$1" | jq -e '.error' >/dev/null; then
57-
echo -e "Your request to Open AI API failed: \033[0;31m$(echo $1 | jq -r '.error.type')\033[0m"
58-
echo $1 | jq -r '.error.message'
57+
echo -e "Your request to Open AI API failed: \033[0;31m$(echo "$1" | jq -r '.error.type')\033[0m"
58+
echo "$1" | jq -r '.error.message'
5959
exit 1
6060
fi
6161
}
@@ -296,7 +296,7 @@ while $running; do
296296
elif [[ "$prompt" =~ ^image: ]]; then
297297
request_to_image "$prompt"
298298
handle_error "$image_response"
299-
image_url=$(echo $image_response | jq -r '.data[0].url')
299+
image_url=$(echo "$image_response" | jq -r '.data[0].url')
300300
echo -e "$OVERWRITE_PROCESSING_LINE"
301301
echo -e "${CHATGPT_CYAN_LABEL}Your image was created. \n\nLink: ${image_url}\n"
302302

0 commit comments

Comments
 (0)