3 ms·
Does anyone take the "don't use cat" stuff seriously?
by tptacek 2y ago
Does anyone take the "don't use cat" stuff seriously?
- tux3 2y agoWell, 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!
- jonjonsonjr 2y agoI 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#harmful-use-of-cat 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.
- rzzzt 2y agoShellCheck does (did): https://www.shellcheck.net/wiki/SC2002 https://www.shellcheck.net/wiki/SC2002
- Ferret7446 2y agoIt'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
- cybrox 2y ago90% 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.
- deleted 2y ago[deleted]
- gorgoiler 2y agoIt’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.
- dieulot 2y ago“<file foo” is POSIX: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_07 https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V... (see the absence of mention that redirection needs to be after the command)
- prmoustache 2y agoDepends 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.