From 44c49099f15d3a5b4cfe893949e143ed4c11aa31 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Wed, 29 Mar 2023 21:32:53 +0300 Subject: [PATCH] Moved to network fd 4 to avoid random crashes on macs --- bopher-ng.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bopher-ng.sh b/bopher-ng.sh index 24c9991..7c1c67e 100755 --- a/bopher-ng.sh +++ b/bopher-ng.sh @@ -66,14 +66,14 @@ trap clear_term INT # fetch any Gopher resource gophetch() { # args: host, port, selector[, input] - exec 3<>/dev/tcp/$1/$2 # bind the descriptor 3 to a /dev/tcp pseudo-device + exec 4<>/dev/tcp/$1/$2 # bind the descriptor 3 to a /dev/tcp pseudo-device if [[ -z "$4" ]]; then - printf '%s\r\n' "$3" >&3 # send the selector string (printf is more reliable) + printf '%s\r\n' "$3" >&4 # send the selector string (printf is more reliable) else - printf '%s\t%s\r\n' "$3" "$4" >&3 # send the selector + tab + input string + printf '%s\t%s\r\n' "$3" "$4" >&4 # send the selector + tab + input string fi - cat <&3 # fetch and output the result (we have to use cat as the result may be binary) - exec 3<&- # close the descriptor to make it reusable + cat <&4 # fetch and output the result (we have to use cat as the result may be binary) + exec 4<&- # close the descriptor to make it reusable } # parse a single Gophermap line according to the current host and port