Commit 4f9b3c59 authored by Ole Christian Eidheim's avatar Ole Christian Eidheim
Browse files

Fixed grep command: always show filename, even when folder contains only one file

parent dae81957
Pipeline #235172732 passed with stages
in 16 minutes and 26 seconds
......@@ -29,15 +29,15 @@ Grep::Grep(const boost::filesystem::path &path, const std::string &pattern, bool
if(extended_regex)
flags += " -E";
auto escaped_pattern = '"' + pattern + '"';
for(size_t i = 1; i < escaped_pattern.size() - 1; ++i) {
auto escaped_pattern = " \"" + pattern + '"';
for(size_t i = 2; i < escaped_pattern.size() - 1; ++i) {
if(escaped_pattern[i] == '"') {
escaped_pattern.insert(i, "\\");
++i;
}
}
std::string command = Config::get().project.grep_command + " -R " + flags + " --color=always --binary-files=without-match " + exclude + " -n " + escaped_pattern + " *";
std::string command = Config::get().project.grep_command + " -RHn --color=always --binary-files=without-match" + flags + exclude + escaped_pattern + " *";
std::stringstream stdin_stream;
Terminal::get().process(stdin_stream, output, command, project_path);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment