Skip to content
This repository

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

Merged
merged 1 commit into from almost 2 years ago

2 participants

Mike Morearty Geoff Greer
Mike Morearty

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.

Mike Morearty 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
Mike Morearty

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

Mike Morearty

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

//Users/mike/foo.txt
Geoff Greer
Owner

Eh, it's better than the current behavior.

Geoff Greer ggreer merged commit 435d0e7 into from
Geoff Greer ggreer closed this
Geoff Greer
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.

Geoff Greer
Owner

Also, my reaction upon seeing your pull request:

Mike Morearty

LOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 03, 2012
Mike Morearty 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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  src/options.c
2  src/options.c
@@ -395,7 +395,7 @@ void parse_options(int argc, char **argv, char **paths[]) {
395 395 path = strdup(argv[i]);
396 396 path_len = strlen(path);
397 397 /* kill trailing slash */
398   - if (path_len > 0 && path[path_len - 1] == '/') {
  398 + if (path_len > 1 && path[path_len - 1] == '/') {
399 399 path[path_len - 1] = '\0';
400 400 }
401 401 (*paths)[i] = path;

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.