Redirects do not work correctly when reassigning std descriptors
dundalek opened this issue · comments
Jakub Dundalek commented
In bash following prints nothing:
bash -c "echo x 1>&2" 2>/dev/null
In closh following prints x:
clojure -m closh.zero.frontend.rebel -e "echo x 1 >& 2" 2>/dev/null
I am not sure if it is possible to bend ProbessBuilder to make it work. We likely need to reach for lower level native APIs.
Some test cases:
(are [x y] (= (bash x) (closh-spawn y))
"echo x 1>&2"
"echo x 1 >& 2"
"bash -c \"echo err 1>&2; echo out\" 2>&1"
"bash -c \"echo err 1>&2; echo out\" 2 >& 1"
"bash -c \"echo err 1>&2; echo out\" 2>&1 | cat"
"bash -c \"echo err 1>&2; echo out\" 2 >& 1 | cat")