Std.process.run and ANSI escape codes

Hello,

I’m working on a dumb personal thing (a shell) and currently I’m launching external commands using std.process.run. However when I get stdout from the result and write it to the parent’s stdout it would appear that the ANSI escape codes are missing. This may be something completely unrelated to how the standard library is handling things and is being caused by something else I am equally ignorant about. I was hoping though that someone could maybe point me in the right direction. I did a bit of digging in the docs and didn’t see anything there. When I check stdout for the parent process (shell) ANSI escape codes are enabled, and also printf works fine so I suspect it has something to do with what the child process sees in it’s env maybe or something in the “handoff” of the stdout data.

How are you setting stdout on the child?
One thing you may be running into is that if you set it as a pipe, you may be confusing the child process. The child process can check if the stdin/stdout file descriptors are ttys. If not, they may decide to not use escape codes because they are acting as if they are being piped somewhere else.

Ah! Thanks, that led me down the right path. std.process.RunOptions has nothing for std*, it would appear based on your help that it does not inerit which makes sense when I think about it more. Using std.process.spawn then calling wait on the child did the trick. std.process.SpawnOptions lets you specify each of the stdIo values (with a default of inherit for each).

Thanks again!