fork download
  1. # foo
  2. # bar
  3. : {fd}< $0
  4. read <&$fd x
  5. echo "$?; $x"
  6. exec {fd}<&-
  7. # a failed read doesn't modify REPLY, so
  8. # use different vars to be less confusing
  9. read <&$fd y
  10. echo "$?; $y"
  11.  
Success #stdin #stdout #stderr 0.01s 5276KB
stdin
Standard input is empty
stdout
0; # foo
1; 
stderr
./prog.sh: line 9: $fd: Bad file descriptor