News for hackers. Stuff that matters.
Re:The Useful Use of Cat by tptacek on Sunday October 20, 2024 @03:55PM (#41898041)
Does anyone take the "don't use cat" stuff seriously?
Re:The Useful Use of Cat by jonjonsonjr on Sunday October 20, 2024 @04:19PM (#41898197)
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 by tux3 on Sunday October 20, 2024 @04:05PM (#41898109)
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 by rzzzt on Sunday October 20, 2024 @04:27PM (#41898229)
Re:The Useful Use of Cat by Ferret7446 on Sunday October 20, 2024 @04:48PM (#41898335)
It's more of a symptom of someone who doesn't understand what's actually going on, i.e. cargo cult scripting.

Specifically, it indicates some combination of:

1. isn't aware of processes/pipes

2. isn't aware of cat's "primary" functionality

3. isn't aware of shell input redirection

4. isn't aware that shell input redirection can be put before the command

Re:The Useful Use of Cat by cybrox on Sunday October 20, 2024 @05:45PM (#41898743)
90% of the time, I care more about someone like that understanding my script than the tiny performance impact of an extra process or 'misusing' a function.
Re:The Useful Use of Cat by gorgoiler on Monday October 21, 2024 @01:56AM (#41901055)
It’s a hump curve with virtue signalling in the middle, like a thousand other things in life.

Noob+naive: use cat because don’t know better.

Experienced+smart ass: use shell direction to distinguish oneself from noobs.

Older+wiser: use cat again because it flows left to right, isn’t bash specific like “<file foo”, doesnt special case examples with only one file as input, and allows something other than a file as input or lifting the body of the pipeline into a function without changing the text…

…but mostly because it doesn’t make one come across as a nit picking asshole to the expensive noobs you’ve just spent months trying to hire.

Re:The Useful Use of Cat by dieulot on Monday October 21, 2024 @02:31AM (#41901228)
“<file foo” is POSIX: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V... (see the absence of mention that redirection needs to be after the command)
Re:The Useful Use of Cat by prmoustache on Monday October 21, 2024 @03:51AM (#41901708)
Depends what you mean by seriously.

If by that you mean religiously avoiding cat at all cost, no. If by that you mean thinking about what you are actually doing on your commandline I say I do. Which makes me realize that yes, cat is more often than not redundant unless you are actually outputting the concatenation of multiple files.