fetch: use a slightly more correct check for TTY stdin

This commit is contained in:
Lucas 2020-05-03 13:53:19 +00:00
parent 06f9918f2c
commit 17ef04b41a

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# fetch # fetch
# Written in 2019 by Lucas # Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved # CC0 1.0 Universal/Public domain - No rights reserved
# #
# To the extent possible under law, the author(s) have dedicated all # To the extent possible under law, the author(s) have dedicated all
@ -12,14 +12,14 @@
usage() usage()
{ {
printf "Usage: %s [-T] URL [URL ...]\n" "${0##*/}">&2 printf "Usage: %s [-T] URL [URL ...]\n" "${0##*/}" >&2
exit 1 exit 1
} }
fetch_cmd() fetch_cmd()
{ {
if [ -t 0 ]; then if tty=$(tty) && [ "$tty" != "not a tty" ]; then
$torsocks ftp "$@" >$(tty) $torsocks ftp "$@" >"$tty"
else else
$torsocks ftp "$@" $torsocks ftp "$@"
fi fi