logoalt Hacker News

ameliusyesterday at 10:54 PM13 repliesview on HN

It's a reminder of how archaic the systems we use are.

File descriptors are like handing pointers to the users of your software. At least allow us to use names instead of numbers.

And sh/bash's syntax is so weird because the programmer at the time thought it was convenient to do it like that. Nobody ever asked a user.


Replies

zahlmanyesterday at 10:59 PM

At the time, the users were the programmers.

show 2 replies
xenadu02today at 12:38 AM

> At least allow us to use names instead of numbers.

You can for the destination. That's the whole reason you need the "&": to tell the shell the destination is not a named file (which itself could be a pipe or socket). And by default you don't need to specify the source fd at all. The intent is that stdout is piped along but stderr goes directly to your tty. That's one reason they are separate.

And for those saying "<" would have been better: that is used to read from the RHS and feed it as input to the LHS so it was taken.

kristopoloustoday at 8:42 AM

I've long wanted easy, trivial multichannel i/o with duplication

I want to be able to route x independent input and y independent output trivially from the terminal

Proper i/o routing

It shouldn't be hard, it shouldn't be unsolved, and it shouldn't be esoteric

show 1 reply
agentdrektoday at 1:00 AM

It should be a lesson to learn on how simple, logical and reliable tools can last decades.

show 3 replies
nusltoday at 1:35 AM

I quite like how archaic it is. I am turned off by a lot of modern stuff. My shell is nice and predictable. My scripts from 15 years ago still work just fine. No, I don't want it to get all fancy, thanks.

varenctoday at 3:51 AM

You can do:

   2>/dev/stdout
Which is about the same as `2>&1` but with a friendlier name for STDOUT. And this way `2> /dev/stdout`, with the space, also works, whereas `2> &1` doesn't which confuses many. But it's behavior isn't exactly the same and might not work in all situations.

And of course I wish you could use a friendlier name for STDERR instead of `2>`

show 1 reply
csoursyesterday at 11:11 PM

The conveniences also mean that there is more than ~one~ ~two~ several ways to do something.

Which means that reading someone else's shell script (or awk, or perl, or regex) is INCREDIBLY inconvenient.

show 1 reply
fulafeltoday at 5:36 AM

They're more like capabilities or handles than pointers. There's a reason in Rust land many systems use handles (indices to a table of objects) in absence of pointer arithmetic.

In the C API of course there's symbolic names for these. STDIN_FILENO, STDOUT_FILENO, etc for the defaults and variables for the dynamically assigned ones.

show 1 reply
Dylan16807today at 3:18 AM

> At least allow us to use names instead of numbers.

You can use /dev/stdin, /dev/stdout, /dev/stderr in most cases, but it's not perfect.

show 1 reply
spiralcoastertoday at 1:02 AM

Who do you imagine the users were back when it was being developed?

show 1 reply
HackerThemAllyesterday at 11:06 PM

> bash's syntax is so weird

What should be the syntax according to contemporary IT people? JSON? YAML? Or just LLM prompt?

show 6 replies
gdevenyitoday at 1:40 AM

The programmers were the users. They asked. They said it was ok.

jballanctoday at 1:44 AM

Wait until you find out where "tty" comes from!