Live data from Hacker News

Ripgrep – A new command line search tool

blog.burntsushi.net

11–20 of 219 posts

Re: Ripgrep – A new command line search tool

#11
post #8

Why not make --with-filename default even for e.g. "rg somestring" ? That seems like it could hinder adoption since grep does it and it's useful when piping to other commands. Is it enabled when you specify a directory (rg somestring .) ?

It should be the default whenever you search more than one file.

Re: Ripgrep – A new command line search tool

#12
post #6

Rust is really staring to be seen in the wild now.

I agree, and I'm already using both ripgrep and rust-parallel ( https://github.com/mmstick/parallel , a gnu-parallel replacement which should probably get another name ).

I am really happy to see Rust apps actually been written -- Rust programmers seem to be actually trying to replace the existing code lying around, instead of just insulting it and telling us how much better the world would be if we used their language.

Re: Ripgrep – A new command line search tool

#13

Thanks for the detailed comparisons and writeup. I find this simple wrapper around grep(1) very fast and useful: http://www.pixelbeat.org/scripts/findrepo

Thanks for the kind words!

Note that the key thing that `findrepo` doesn't support is respecting your .gitignore files. For example, in the Rust ecosystem, we often have a `target` directory in our projects that contains a lot of stuff we probably don't want to search. In fact, running `cargo new` will add that directory to your `.gitignore` automatically!

Tools like The Silver Searcher and ripgrep will ignore that directory (and all others like it) automatically.

There are other advantages to ripgrep. For example, every other tool that supports Unicode as well as ripgrep (that's `git grep` and GNU grep) experience a substantial slow down when trying to use more advanced Unicode features (like \w, -i, etc.). This is one of the things my benchmarks show.

Re: Ripgrep – A new command line search tool

#14
post #2

nice, but does it compile and run on armhf? I don't see any binaries

I was able to build ripgrep from source for ARM, cross-compiling from my laptop running Debian, following the directions here:

https://github.com/japaric/rust-cross#tldr-ubuntu-example

(I haven't actually run it because I don't have an ARM linux device handy.)

Re: Ripgrep – A new command line search tool

#16
post #15

To build a static Linux binary with SIMD support, run this: RUSTFLAGS="-C target-cpu=native" rustup run nightly cargo build --target x86_64-unknown-linux-musl --release --features simd-accel

That's an awesome demonstration of how easy it is to swap out the libc in Rust. :-)

Note that I also distribute statically compiled executables with musl and SIMD enabled (using target-feature=+ssse3 instead of target-cpu=native): https://github.com/BurntSushi/ripgrep/releases

Re: Ripgrep – A new command line search tool

#17
Nice! Lightgrep[1] uses libicu et al to look up code points for a user-specified encoding and encode them as bytes, then just searches for the bytes. Since ripgrep is presumably looking just for bytes, too, and compiling UTF-8 multibyte code points to a sequence of bytes, perhaps you can do likewise with ICU and support other encodings. ICU is a bear to build against when cross-compiling, but it knows hundreds of encodings, all of the proper code point names, character classes, named properties, etc., and the surface area of its API that's required for such usage is still pretty small.

[1]: http://strozfriedberg.github.io/liblightgrep

Re: Ripgrep – A new command line search tool

#19
post #15

To build a static Linux binary with SIMD support, run this: RUSTFLAGS="-C target-cpu=native" rustup run nightly cargo build --target x86_64-unknown-linux-musl --release --features simd-accel

That's an awesome demonstration of how easy it is to swap out the libc in Rust. :-) Note that I also distribute statically compiled executables with musl and SIMD enabled (using target-feature=+ssse3 instead of target-cpu=native): https://github.com/BurntSushi/ripgrep/releases

> That's an awesome demonstration of how easy it is to swap out the libc in Rust. :-)

Now I have to look up how I use cargo to build a static binary on FreeBSD, where I don't have to swap out libc.

> Note that I also distribute statically compiled executables with musl and SIMD enabled (using target-feature=+ssse3 instead of target-cpu=native): https://github.com/BurntSushi/ripgrep/releases

I took the flag from your blog post, thanks for pointing out the explicit feature flag. That will allow the binary to run on more cpus.

Re: Ripgrep – A new command line search tool

#20
post #6

Rust is really staring to be seen in the wild now.

I agree, and I'm already using both ripgrep and rust-parallel ( https://github.com/mmstick/parallel , a gnu-parallel replacement which should probably get another name ). I am really happy to see Rust apps actually been written -- Rust programmers seem to be actually trying to replace the existing code lying around, instead of just insulting it and telling us how much better the world would be if we used their langua…

Honestly, for a certain kind of developer—I haven't fingerpointed exactly which kind—writing Rust code is dangerously addictive. There's some combination of aggressive type checking, tooling, and expressiveness that just hits a sweet spot in my brain.

Rust fills roughly the same niche in my brain as old-school C++, except it also lets me do some rudimentary functional stuff, there are virtually no footguns, and the CLI tooling is out of this world. And I've long since made friends with the borrow checker. So it's tempting to just spend my life cranking out Rust code as fast as I can. It's actually a problem. :-)

Post reply on HN