From 68e11fc972b1ae1b0ce4a6115a16918ecce518a6 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 3 Aug 2022 03:27:43 +0000 Subject: [PATCH] fetch: explain why we call tty(1) While at it, also use safe test operands. --- bin/fetch.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/fetch.sh b/bin/fetch.sh index b5f4be6..ba6a1de 100644 --- a/bin/fetch.sh +++ b/bin/fetch.sh @@ -1,6 +1,6 @@ #!/bin/sh # fetch -# Written in 2019-2021 by Lucas +# Written in 2019-2022 by Lucas # CC0 1.0 Universal/Public domain - No rights reserved # # To the extent possible under law, the author(s) have dedicated all @@ -18,7 +18,11 @@ usage() 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" else $torsocks ftp "$@"