fetch: explain why we call tty(1)

While at it, also use safe test operands.
This commit is contained in:
Lucas 2022-08-03 03:27:43 +00:00
parent fc3171ae5e
commit 68e11fc972

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# fetch # fetch
# Written in 2019-2021 by Lucas # Written in 2019-2022 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
@ -18,7 +18,11 @@ usage()
fetch_cmd() fetch_cmd()
{ {
if tty=$(tty) && [ "$tty" != "not a tty" ]; then # ftp(1) is chatty if stdin is a terminal. It prints its operations to
# stdout if "-o output" is used. In that case, we'll need to redirect
# stdout to the tty we're being called from, in order to be able to
# pipe the output to another command.
if tty=$(tty) && [ X"$tty" != X"not a tty" ]; then
$torsocks ftp "$@" >"$tty" $torsocks ftp "$@" >"$tty"
else else
$torsocks ftp "$@" $torsocks ftp "$@"