Skip to main content
Added usage of mktemp in order to generate a dynamic file name in /tmp for the temporary file instead of fixed file name "foo-status"
Source Link

With a bit of precaution, this should work:

foo-status=$(mktemp -t)
(foo; echo $? >foo>$foo-status) | bar
foo_status=$(cat foo$foo-status)

With a bit of precaution, this should work:

(foo; echo $? >foo-status) | bar
foo_status=$(cat foo-status)

With a bit of precaution, this should work:

foo-status=$(mktemp -t)
(foo; echo $? >$foo-status) | bar
foo_status=$(cat $foo-status)
Source Link
alex
  • 7.5k
  • 6
  • 31
  • 30

With a bit of precaution, this should work:

(foo; echo $? >foo-status) | bar
foo_status=$(cat foo-status)