I think I have finally managed to articulate this very fundamental but slightly counterintuitive fact about how shell redirection works

it's always kind of interesting to think about alternative ways running programs "could" work

like you could imagine that the `execve` system call works something like

execve("/usr/bin/sudo", ["sudo", "echo", "blah"], environment=..., stdout="file.txt", )

and then the program is responsible for opening "file.txt", the same way it would be if you passed `file.txt` as a command line argument

of course that is not how things work but it doesn't feel like that outrageous of a mental model

Follow

@b0rk Unless you could also inherit fds and specify /dev/fd/N there, this would make it harder to avoid race conditions and require replacement of many pipes with named fifos.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.