Live data from Hacker News

The useful use of cat

mrmr.io

11–20 of 113 posts

Re: The useful use of cat

#13
post #4

"A la test driven development. " I would not call that test driven development (where are the testcases?) Rather more like REPL driven programming.

Whether there are formal examples or not, the thing you're doing during REPL driven programming is testing. It's just rapid, iterative and informal.

Re: The useful use of cat

#14
post #9

Does anyone take the "don't use cat" stuff seriously?

Well, this is the internet!

We had just gotten over tabs vs spaces after barely a thousand years of noticing the other side is objectively wrong.

Something new that you're definitely doing wrong to blog and argue and bicker about; it can't be helped!

Re: The useful use of cat

#15
post #10

You can still just begin with <somefile instead of cat somefile |. Does it really matter? No, but I don’t think pointing out useful and concise built-ins is necessarily asinine.

Yeah, there are still some edge cases where cat is useful, but more often than not I just begin the redirection. I reckon some don't realize you can put it at the beginning, which does sometimes feel more ergonomic in a pipeline.

It's not that it feels awkward to write the redirection first. It's that it feels awkward to write `< file cmd`, with no operator between the filename and the command, and the redirection operator not pointing at the command.

Re: The useful use of cat

#16
post #4

"A la test driven development. " I would not call that test driven development (where are the testcases?) Rather more like REPL driven programming.

Whether there are formal examples or not, the thing you're doing during REPL driven programming is testing . It's just rapid, iterative and informal.

TDD refers to a specific kind of testing methodology, not just any and all testing. Manual testing is not TDD.

Re: The useful use of cat

#18
post #10

You can still just begin with <somefile instead of cat somefile |. Does it really matter? No, but I don’t think pointing out useful and concise built-ins is necessarily asinine.

Yeah, there are still some edge cases where cat is useful, but more often than not I just begin the redirection. I reckon some don't realize you can put it at the beginning, which does sometimes feel more ergonomic in a pipeline.

A pipeline without pipes connecting is just a field of shit

Re: The useful use of cat

#19
post #9

Does anyone take the "don't use cat" stuff seriously?

I tend to agree with this sentiment but this year I came across two situations where the use of cat is actually harmful and not just useless: https://github.com/jonjohnsonjr/til/blob/main/post/readat.md...

I still instinctively start my pipelines with cat half the time, but now I have complicated feelings about it.

Re: The useful use of cat

#20

You can still just begin with <somefile instead of cat somefile |. Does it really matter? No, but I don’t think pointing out useful and concise built-ins is necessarily asinine.

No, in ordinary usage it doesn't matter, and it's not like I would go out of my way to change someone else's script code.

But if teaching or demonstrating shell features, I'd say that it's important to know that redirection is the most efficient, explicit, and available method.

Indeed, a student could learn "cat file | ..." as a standard idiom and never use an initial redirect, but what happens when they come across one "in the wild"? They should know its proper interpretation, because it can otherwise be a bit jarring to see and difficult to interpret.

Post reply on HN