I have a simple script that checks if an interface is connected:
connected=$(ping -I $1 -qc 1 220.127.116.11 \ && echo "connected" \ || echo "not connected") echo "$connected" | tail -n1
I'm expecting that it should simply return "connected" or "not connected". When I actually use the script I always get back a warning before my output.
ping: Warning: source address might be selected on device other than enp0s25. not connected
What is with the warning here, shouldn't it be part of the subshell?