diff --git a/shell/AIShell.Kernel/Command/AgentCommand.cs b/shell/AIShell.Kernel/Command/AgentCommand.cs index 63522feb..7d993fd5 100644 --- a/shell/AIShell.Kernel/Command/AgentCommand.cs +++ b/shell/AIShell.Kernel/Command/AgentCommand.cs @@ -166,6 +166,26 @@ private void ConfigAgentAction(string name, string editor) else { // On macOS and Linux, we just depend on the default editor. + FileInfo fileInfo = new(settingFile); + if (fileInfo.Exists) + { + UnixFileMode curMode = fileInfo.UnixFileMode; + UnixFileMode newMode = curMode & ~(UnixFileMode.UserExecute | UnixFileMode.GroupExecute | UnixFileMode.OtherExecute); + + if (newMode != curMode) + { + try + { + File.SetUnixFileMode(settingFile, newMode); + } + catch (UnauthorizedAccessException) + { + host.WriteErrorLine($"The setting file '{settingFile}' is incorrectly configured with the 'execute' permission. Please remove the 'execute' permission and try again."); + return; + } + } + } + info = new(settingFile) { UseShellExecute = true }; Process.Start(info); }