Lurker News

Comments (136) 27 threads

Show all comments

Showing thread 8 of 27

GrayShade4 replies#
Cool project (and written in my favourite language), but I really hate how there's no space at the end of your prompt.
flusteredBias1 reply#
Love the idea! Already opened the issue and will merge a PR before the next release.
flusteredBias#
lol. Got it.
stavros#
I have to agree, I felt dirty watching the recording. The project looks great, though.
BiteCode_dev1 reply#
It feels like when somebody opens a ( but doesn't close it.
hoosieree1 reply#
)
BiteCode_dev#
There is such a big latency in HN for self closing parenthesis.
lambic1 reply#
And the use of cat on a single file..
netcraft1 reply#
I don't understand your comment - could you expand on it?
ComputerGuru2 replies#
cat just regurgitates the contents of the file, but the resulting piped fd is non-seekable. Since almost every command that can operate on a file from stdin can also operate on the file by name/path, at best this is just a needless invocation of a process (i.e. `tv foo.csv` should have been used instead of `cat foo.csv | tv`) - if the app in question can't handle paths, then you can have the shell pipe the file into it instead (e.g. `tv < foo.csv`). At worst, the recipient program would need to buffer the entire contents of the input if it needs to perform non-sequential operations on the source data - this is the case with things like `tac` that need to seek to the end of the input (see https://github.com/neosmart/tac for how `cat foo | tac` requires buffering but both `tac foo` and even `tac < foo` don't).
netcraft1 reply#
thank you! I knew some of that but learned a lot too.
mthoms2 replies#
Google the phrase "useless use of cat".

To some, it's a faux-pas. Personally, I like the aesthetics of cat for my own scripts. It follows the "pipe flowing" idiom better.
There are performance reasons why "useless cat" should be avoided though. So avoid it where performance is important (or when some other hardcore CLI jockey is going to see your code :))

hibbelig#
I understand that people say you can replace

    foo < bar
with


but I've never been able to get myself to do this.
bofh23#
Avoiding “useless cat” on the command line is premature optimization. Sure, don’t do it in a script that is invoked a lot but it shouldn’t be a concern when prototyping a filter pipeline.

  $ cat foo | head -4
  b
  a
  c
  b

  $ cat foo | head -4 | sort
  a
  b
  b
  c

  $ cat foo | head -4 | sort | uniq -c
  1 a
  2 b
  1 c

  $ cat foo | head -4 | sort | uniq -c | sort -k1nr | head -1
  2 b