执行shell
(commands string)
| 129 | |
| 130 | // 执行shell |
| 131 | func (prov *CodeCompileProvider) shell(commands string) (success bool, errout string) { |
| 132 | ctx, _ := context.WithTimeout(context.Background(), 7*time.Second) |
| 133 | cmdArgs := strings.Split(commands, " ") |
| 134 | if len(cmdArgs) <= 1 { |
| 135 | return false, "not enough arguments for compiler" |
| 136 | } |
| 137 | ret, err := utils.RunUnixShell(&structs.ShellOptions{ |
| 138 | Context: ctx, |
| 139 | Name: cmdArgs[0], |
| 140 | Args: cmdArgs[1:], |
| 141 | StdWriter: nil, |
| 142 | OnStart: nil, |
| 143 | }) |
| 144 | if err != nil { |
| 145 | return false, err.Error() |
| 146 | } |
| 147 | if !ret.Success { |
| 148 | return false, ret.Stderr |
| 149 | } |
| 150 | return true, "" |
| 151 | } |
| 152 | |
| 153 | // 存储代码到文件 |
| 154 | func (prov *CodeCompileProvider) saveCode() error { |
nothing calls this directly
no test coverage detected