mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-14 08:01:02 -07:00
Making shell:true as default and adding -I to grep (#11448)
Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import { isGitRepository } from '../utils/gitUtils.js';
|
||||
import type { Config } from '../config/config.js';
|
||||
import type { FileExclusions } from '../utils/ignorePatterns.js';
|
||||
import { ToolErrorType } from './tool-error.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
|
||||
// --- Interfaces ---
|
||||
|
||||
@@ -219,10 +220,16 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
try {
|
||||
const child = spawn(checkCommand, checkArgs, {
|
||||
stdio: 'ignore',
|
||||
shell: process.platform === 'win32',
|
||||
shell: true,
|
||||
});
|
||||
child.on('close', (code) => resolve(code === 0));
|
||||
child.on('error', () => resolve(false));
|
||||
child.on('error', (err) => {
|
||||
debugLogger.debug(
|
||||
`[GrepTool] Failed to start process for '${command}':`,
|
||||
err.message,
|
||||
);
|
||||
resolve(false);
|
||||
});
|
||||
} catch {
|
||||
resolve(false);
|
||||
}
|
||||
@@ -385,10 +392,14 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
}
|
||||
|
||||
// --- Strategy 2: System grep ---
|
||||
console.debug(
|
||||
'GrepLogic: System grep is being considered as fallback strategy.',
|
||||
);
|
||||
|
||||
const grepAvailable = await this.isCommandAvailable('grep');
|
||||
if (grepAvailable) {
|
||||
strategyUsed = 'system grep';
|
||||
const grepArgs = ['-r', '-n', '-H', '-E'];
|
||||
const grepArgs = ['-r', '-n', '-H', '-E', '-I'];
|
||||
// Extract directory names from exclusion patterns for grep --exclude-dir
|
||||
const globExcludes = this.fileExclusions.getGlobExcludes();
|
||||
const commonExcludes = globExcludes
|
||||
|
||||
Reference in New Issue
Block a user