Closed ezrizhu closed 2 months ago
Nice! Could we add one more test that actually uses these streams, rather than just testing that the devices exist?
Here's a simple test script that reads a number
x
from stdin and outputs2x
on stdout and3x
on stderr:read x echo $((x * 2)) echo $((x * 3)) >&2
We should be able to run
echo 5 | try $SCRIPT
and get 10 on stdout and 15 on stderr. Similarly, we should be able to runecho 5 >FILE; try $SCRIPT <FILE
(NB redir is in our shell, not in try's arg) and get the same result.
That example would also pass outside of this PR since it seems like sh does not need /dev/std{in,out,err} for those streams. @mgree
That example would also pass outside of this PR since it seems like sh does not need /dev/std{in,out,err} for those streams. @mgree
Oh! Good point lol. Then we should write a test that uses those devices appropriately.
symlinks /dev/std{in,out,err} to /proc/self/fd/{0,1,2} and cleanup after tests included