我正在尝试通过 C# 中的 bash 运行 cygwin 命令,并尝试使用 read 命令保持结果打开。我的代码似乎是打开 bash 然后立即关闭。我究竟做错了什么?
static void Main(string[] args)
{
Process bashProcess = new Process();
bashProcess.StartInfo.FileName = @"C:\cygwin64\bin\bash.exe";
bashProcess.StartInfo.Arguments = "-l -c echo blah; read";
bashProcess.StartInfo.UseShellExecute = true;
bashProcess.Start();
bashProcess.WaitForExit();
System.Console.WriteLine("Exit Code: {0}", bashProcess.ExitCode);
System.Console.WriteLine("Press enter to exit...");
System.Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)