Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix search that starts at root directory "/" #85

Merged
merged 1 commit into from

2 participants

@mmorearty

Currently, ag fails if the user does a search starting at the root directory of the hard disk, specifying nothing more than "/" for the directory, e.g. "ag foo /". This patch fixes that admittedly rare edge case.

@mmorearty mmorearty Fix search that starts at root directory "/"
Fix so that the user can do a search starting at the
root directory, e.g. "ag foo /"
5ad53d7
@mmorearty

Never mind my previous (now-deleted) comment :-P

@mmorearty

Bleah. My patch works, but it results in ag displaying paths like this for matched files:

//Users/mike/foo.txt
@ggreer
Owner

Eh, it's better than the current behavior.

@ggreer ggreer merged commit 435d0e7 into from
@ggreer
Owner

Feel free to reopen or submit a new PR or whatever to fix the path printing. I'll warn you though: print.c is an abomination.

@ggreer
Owner

Also, my reaction upon seeing your pull request:

@mmorearty

LOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 3, 2012
  1. @mmorearty

    Fix search that starts at root directory "/"

    mmorearty authored
    Fix so that the user can do a search starting at the
    root directory, e.g. "ag foo /"
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  src/options.c
View
2  src/options.c
@@ -395,7 +395,7 @@ void parse_options(int argc, char **argv, char **paths[]) {
path = strdup(argv[i]);
path_len = strlen(path);
/* kill trailing slash */
- if (path_len > 0 && path[path_len - 1] == '/') {
+ if (path_len > 1 && path[path_len - 1] == '/') {
path[path_len - 1] = '\0';
}
(*paths)[i] = path;
Something went wrong with that request. Please try again.