You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] cmd &>file runs cmd in the background and redirects nothing (ls /missing &>/dev/null; echo $? prints 0) #369
Same as bash: &>file sends stdout and stderr to the file.
rc=2
file=[hi]
with nothing on stderr.
Actual Behavior
rc=0
hi
file=[]
and ls: cannot access '/nonexistent-dir': No such file or directory on stderr.
Additional Context
The output is what cmd & >file would give: the command's output isn't redirected, $? is 0 instead of the command's status, and the file is created empty. I haven't read the parser to confirm that is how &> is split.
cmd >/dev/null 2>&1 works: ls /nonexistent-dir >/dev/null 2>&1; echo "rc=$?" prints rc=2 with nothing on stderr.
cmd &>/dev/null is a common way to silence a command and then check its status, so a script gets the wrong status and the output it tried to hide.
Found while reviewing #348; it is not caused by that PR. The results are the same on main @ dbb6189 and on #348's head 9ef3e56. I ran debug builds through -c only and compared with bash 5.2.15.
The other bash spelling of this, cmd >&file, also fails, in a different way: the redirect is rejected and the command doesn't run. Worth fixing together.
strands-shell -c 'echo hi >&out.txt; echo "rc=$?"'
bash writes hi to out.txt and prints rc=0. main @ dbb6189 prints strands-shell: out.txt: bad file descriptor and rc=1, and creates no file. src/exec.rs:1772-1774 parses the word after >& as an fd number and has no fallback for a file name.
Found while reviewing #346. Once that merges, command -v X >&/dev/null takes this path as well (as type X >&/dev/null already does), so if command -v cd >&/dev/null; then … takes the else branch.
Activity
strandly-the-agent commentedon Nov 21, 2026
The other bash spelling of this,
cmd >&file, also fails, in a different way: the redirect is rejected and the command doesn't run. Worth fixing together.strands-shell -c 'echo hi >&out.txt; echo "rc=$?"'bash writes
hitoout.txtand printsrc=0.main@dbb6189printsstrands-shell: out.txt: bad file descriptorandrc=1, and creates no file.src/exec.rs:1772-1774parses the word after>&as an fd number and has no fallback for a file name.Found while reviewing #346. Once that merges,
command -v X >&/dev/nulltakes this path as well (astype X >&/dev/nullalready does), soif command -v cd >&/dev/null; then …takes theelsebranch.