diff --git a/bin/fetch.sh b/bin/fetch.sh index 5dc100c..40e3cf8 100644 --- a/bin/fetch.sh +++ b/bin/fetch.sh @@ -9,12 +9,21 @@ # warranty. You should have received a copy of the CC0 Public Domain # Dedication along with this software. If not, see # . - -usage() { +usage() +{ printf "Usage: %s [-T] URL [URLs...]\n" "${0##*/}">&2 exit 1 } +fetch_cmd() +{ + if [ -t 0 ]; then + $torsocks ftp "$@" >$(tty) + else + $torsocks ftp "$@" + fi +} + torsocks=torsocks while getopts T flag; do case $flag in @@ -52,7 +61,7 @@ for url; do mkdir -p "$outdir" { - $torsocks ftp -o "$outdir/file" "$url" \ + fetch_cmd -o "$outdir/file" "$url" \ && printf "%s\n" "$url" >"$outdir/url" \ && printf "%s\n" "$name" >"$outdir/name" \ && printf "%s\n" "$url" >>"$everything" \