commit ff252d24d0dfeca029de1f2fac019696a7848d8c parent 5fed6b41ddd30bfbcf45126788a9d7fee46998f3 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Thu, 29 Aug 2019 11:13:35 +0200 Fix get functionality Diffstat:
M | .local/bin/upload | | | 33 | ++++++++++++++++----------------- |
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/.local/bin/upload b/.local/bin/upload @@ -149,27 +149,26 @@ if [ $# -lt 1 ]; then show_help exit 1 fi - -if [ ! -f "$1" ]; then - msg="$(cat)" - tempfile="$(mktemp)" - printf "%s" "$msg" > "$tempfile" - - preprocess_file "$tempfile" "$1" - upload_file "$tempfile" "$(basename "$1")" -else - # loop over FILE[S] + +if [ "$get" = 1 ]; then for f in "$@"; do - [ ! -f "$f" ] && die "Error: $f is not a file" - + download_file "$(basename "$f")" + done +else + if [ ! -f "$1" ]; then + msg="$(cat)" + tempfile="$(mktemp)" + printf "%s" "$msg" > "$tempfile" - if [ "$get" = 1 ]; then - download_file "$(basename "$f")" - else + preprocess_file "$tempfile" "$1" + upload_file "$tempfile" "$(basename "$1")" + else + for f in "$@"; do + [ ! -f "$f" ] && die "Error: $f is not a file" tempfile="$(mktemp)" cp "$f" "$tempfile" preprocess_file "$tempfile" "$1" upload_file "$tempfile" "$(basename "$f")" - fi - done + done + fi fi