|
@ -91,10 +91,9 @@ public class LinuxCommandExecutor : BaseCommandExecutor |
|
|
throw new ArgumentException("命令不能为空", nameof(command)); |
|
|
throw new ArgumentException("命令不能为空", nameof(command)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 使用双引号包裹整个命令,并对特殊字符进行转义
|
|
|
// 使用双引号包裹整个命令,只对必要的特殊字符进行转义
|
|
|
var escapedCommand = command |
|
|
var escapedCommand = command |
|
|
.Replace("\"", "\\\"") |
|
|
.Replace("\"", "\\\"") |
|
|
.Replace("$", "\\$") |
|
|
|
|
|
.Replace("`", "\\`") |
|
|
.Replace("`", "\\`") |
|
|
.Replace("\\", "\\\\"); |
|
|
.Replace("\\", "\\\\"); |
|
|
|
|
|
|
|
|