Force exact match for `gem list`

rubygems

Solution

You are basically entering a regex on the command line, so

gem list -r ^rails$

does an exact search without piping. I'm using rubygems 2.0.6 and 2.4.5 and it worked on both versions.

I couldn't find anything to put in .gemrc, though. You could easily set up a wrapper shell script for your most common case.

Problem

`gem list rails` used to match everything that began with "rails" (and the documentation still claims it works that way) but at some point it started matching everything that includes rails anywhere in the name. This can get ridiculous, as there are (at the moment I write this, but I'm sure it goes up practically by the hour) 2,764 items that match "rails": ``` gem list rails --remote | wc -l 2764 ``` Can Rubygems be made to only return exact matches by default? I don't see any commandline switches that force an exact match. Perhaps a setting in `~/.gemrc`? Obviously I can do this by piping the output to other utilities, but that's kind of a pain to do every time you just want to (e.g.) check the latest version of a gem, and it's a lot slower, and forces you to stop and think about a detail that (IMO) is a distraction from whatever problem you're working on. ``` gem list rails --remote | grep '^rails ' ``` Is there a good way to make this the default?

Original source