Merge branch 'jk/grep-tell-run-command-to-cd-when-running-pager'
[gitweb.git] / builtin / grep.c
index 69ac2d8797ec32dc206425db0a2f3d7356810cfe..43af5b744fcbeef343672637b3e9058014b6353c 100644 (file)
@@ -361,9 +361,7 @@ static void run_pager(struct grep_opt *opt, const char *prefix)
                argv[i] = path_list->items[i].string;
        argv[path_list->nr] = NULL;
 
-       if (prefix && chdir(prefix))
-               die(_("Failed to chdir: %s"), prefix);
-       status = run_command_v_opt(argv, RUN_USING_SHELL);
+       status = run_command_v_opt_cd_env(argv, RUN_USING_SHELL, prefix, NULL);
        if (status)
                exit(status);
        free(argv);