File tree Expand file tree Collapse file tree
mcp/mcp-cli-api/src/main/java/software/amazon/smithy/java/mcp/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -398,12 +398,14 @@ private static boolean tryAddToShellConfigs(String shimsDirStr) {
398398 for (var configFile : configFiles ) {
399399 var configPath = resolveFromHomeDir (configFile );
400400
401- if (Files .exists (configPath )) {
401+ if (Files .exists (configPath ) && Files . isWritable ( configPath ) ) {
402402 try {
403403 // Check if already present
404404 var lines = Files .readAllLines (configPath , StandardCharsets .UTF_8 );
405405 boolean alreadyPresent = lines .stream ()
406- .anyMatch (line -> line .contains (shimsDirStr ) && line .contains ("PATH" ));
406+ .anyMatch (line -> line .contains (shimsDirStr )
407+ && line .contains ("PATH" )
408+ && !(line .trim ().startsWith ("#" )));
407409
408410 if (!alreadyPresent ) {
409411 // Add the export statement
You can’t perform that action at this time.
0 commit comments