From 43c468e33691665d16d234f3d74ba6291f21c7c2 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 22 Jan 2016 16:47:58 +0100 Subject: [PATCH] Fix loop --- bashbot.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index b0c473d..7d32d7b 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -70,12 +70,14 @@ send_keyboard() { local text="$2" shift 2 local keyboard=init - for f in $*;do local keyboard="$keyboard, [\"$f\"]";done + OLDIFS=$IFS + IFS=$(echo -en "\"") + for f in $*;do [ ! -z "$f" ] && local keyboard="$keyboard, [\"$f\"]";done + IFS=$OLDIFS local keyboard=${keyboard/init, /} res=$(curl -s "$MSG_URL" --header "content-type: multipart/form-data" -F "chat_id=$chat" -F "text=$text" -F "reply_markup={\"keyboard\": [$keyboard],\"one_time_keyboard\": true}") } - get_file() { [ "$1" != "" ] && echo $FILE_URL$(curl -s "$GET_URL" -F "file_id=$1" | ./JSON.sh -s | egrep '\["result","file_path"\]' | cut -f 2 | cut -d '"' -f 2)