Moved to network fd 4 to avoid random crashes on macs
This commit is contained in:
+5
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user