Great question! The difference in exit codes (${PIPESTATUS[@]}) between your two commands comes down to how pipelines and exit codes are handled in Bash, especially when tee is involved.
In Bash, a pipeline (commands chained with |) only returns the exit code of the last command in the pipeline by default. This is why your second command (without tee) only shows 0 1:
0: Exit code of ls_secret (success).1: Exit code of sudo openconnect (failure).${PIPESTATUS[@]}${PIPESTATUS[@]} is an array that stores the exit codes of all commands in the last pipeline. This is why your first command (with tee) shows 0 141 130:
0: Exit code of ls_secret (success).141: Exit code of sudo openconnect (likely SIGPIPE, since tee closed its input early).130: Exit code of tee (likely SIGINT or manual interruption).141 and 130?141: This is 128 + 13 (SIGPIPE). It means openconnect tried to write to a pipe that was closed (likely because tee terminated early, e.g., due to a manual interrupt or error).130: This is 128 + 2 (SIGINT). It means tee was interrupted (e.g., you pressed Ctrl+C).tee, only the last command's exit code is shown (1 for openconnect).tee, ${PIPESTATUS[@]} reveals the exit codes of all commands in the pipeline, including tee itself.141 and 130 suggest that either:
tee was interrupted, orCtrl+C), causing tee to exit with 130 and openconnect to fail with 141 (SIGPIPE).openconnect is failing due to authentication or network issues.openconnect without tee to see its direct output.Would you like help troubleshooting the VPN connection itself?
This Chat is read-only. Login to resume chatting.