logoalt Hacker News

jedahanlast Sunday at 1:20 AM2 repliesview on HN

I was wondering the same thing. My best guess is that is to guard against operator misuse. Like usb-a only plugging in one way. Anything that is secret will never accidentally print to stdout. String interpolation in bash with `—option $empty` might be safer than `8<$empty`. Have to explore more but yeah, this is a new pattern for me as well.


Replies

yellowapplelast Sunday at 5:57 AM

Another possible factor driving the decision to use numbered file descriptors: the logic to validate that a file exists (or can exist) at a given path, is readable/writable, etc. gets punted to the shell instead of being something the program itself has to worry about.

gnulllast Sunday at 6:29 AM

Those descriptors like 5 could be mapped to anything, including descriptor 1, stdout.