sandbox exec stdout piping broken when stdin is a TTY
When running miren sandbox exec with stdout redirected to a file (e.g., miren sandbox exec -i myapp cat /data/db > backup.db), the output still goes to the terminal instead of the file.
The problem is in cli/commands/sandbox_exec.go. The TTY detection only checks whether stdin is a console (line 41), and when it is, it sets both in and out to the console object. This means stdout redirection from the shell is ignored because the program never writes to os.Stdout.
// Current behavior (line 41-81):
if con, err := console.ConsoleFromFile(os.Stdin); err == nil {
in = con
out = con // <-- always writes to console, ignoring stdout redirect
The fix should check stdout independently: only use the console for output when stdout is also a TTY. When stdout is redirected, use os.Stdout for output and skip sending window size to avoid server-side PTY allocation (which mangles binary data).
Workaround: pipe /dev/null into stdin to force the non-TTY code path:
miren sandbox exec -i myapp cat /data/db < /dev/null > backup.db
This came up when Brian was trying to back up a SQLite database from a sandbox.