79717319

Date: 2025-07-28 12:30:40
Score: 0.5
Natty:
Report link

The reason your rc is not updated in your example is because bash will create a subshell when using a pipe

One solution to your problem is to use "${PIPESTATUS[@]}"

#!/usr/bin/bash

curl --max-time 5 "https://google.com" | tee "page.html"

echo "curl return code: ${PIPESTATUS[0]}"
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: izissise