Odd inconsistency between executing and sourcing Bash script
12
votes
1
answer
1757
views
I know this is not a very descriptive title (suggestions are welcome), but the fact is that I've been pulling my hair over this for hours and I have no clue where the root of the problem might lie.
I wrote a simple Bash script for CLI chat between peers on a local network:
#!/usr/bin/env bash
# Usage: ./lanchat : :
# set -x
set -o errexit -o nounset -o pipefail
IFS=':' read -a socket "$RECV_FIFO"; done &
TMUX_TOP="while true; do cat '$RECV_FIFO'; done"
TMUX_BOTTOM="while IFS= read -r line; do nc -n -q 0 '$REMOTE_IP' '$REMOTE_PORT' .tmp.lanchat; done &
$ tmux new "while true; do cat .tmp.lanchat; done" \; split -v "while IFS= read -r line; do nc -n -q 0 172.16.0.100 1234 "$RECV_FIFO";
done &
#...
I tried establishing the connection in all possible orders between the two peers. I even restarted both the server and my local machine to make sure that there were no orphaned or zombie instances of *nc* hugging the socket that had somehow evaded detection.
Now, Debian and Arch run different versions of *nc*. So, on the face of it, it sounds like this could be a possible explanation. But doesn't the fact that sourcing the script on Debian's side works fine rule out that possibility?
What the heck is going on, here?
Asked by mesr
(429 rep)
Feb 26, 2024, 03:50 AM
Last activity: Mar 1, 2024, 06:45 PM
Last activity: Mar 1, 2024, 06:45 PM