From ccac62dd720335b71cb16ce7875d87cc390f21eb Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sat, 6 Feb 2021 17:38:37 +0100 Subject: [PATCH] download_file: return normalised absolute path --- bashbot.sh | 5 +++-- doc/6_reference.md | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index e28fd54..cb11af8 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb # 8 - curl/wget missing # 10 - not bash! # -#### $$VERSION$$ v1.41-dev-6-g0702d58 +#### $$VERSION$$ v1.41-dev-9-g5294d00 ################################################################## # are we running in a terminal? @@ -457,7 +457,8 @@ download_file() { file="${DATADIR:-.}/${file//\//-}" [ -f "${file}" ] && file="$(mktemp -p "${DATADIR:-.}" "XXXXX-${file##*/}" )" getJson "${url}" >"${file}" || return - printf '%s\n' "${file}" + # output absolute file path + printf "%s\n" "$(cd "${file%/*}" >/dev/null 2>&1 && pwd)/${file##*/}" } diff --git a/doc/6_reference.md b/doc/6_reference.md index 107bc0f..d4cf2da 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -539,7 +539,7 @@ edit_html_message "${CHAT[ID]}" "${saved-id}" "this is html text" ### Get files from Telegram ##### download_file -`download_file` download a file to DATADIR and returns the PATH to the file, main use is to download files send to chats. +`download_file` download a file to `DATADIR` and returns the local `path` to the file on disc, main use is to download files send to chats. I tried to be as compatible as possible with old function `download`. *usage:* download_file path_to_ile prosed_filename @@ -1627,5 +1627,5 @@ The name of your bot is available as bash variable "$ME", there is no need to ca #### [Prev Best Practice](5_practice.md) #### [Next Notes for Developers](7_develop.md) -#### $$VERSION$$ v1.41-dev-8-gb91e96d +#### $$VERSION$$ v1.41-dev-9-g5294d00