| 181 | } |
| 182 | |
| 183 | func executePWithOptionsWithExecRead( |
| 184 | wsl wsllib.WslLib, |
| 185 | name string, |
| 186 | opts runPOptions, |
| 187 | execRead func(wsllib.WslLib, string, string) (string, uint32, error), |
| 188 | ) error { |
| 189 | var convArgs []string |
| 190 | for _, s := range opts.commandArgs { |
| 191 | if strings.Contains(s, "\\") { |
| 192 | s = strings.Replace(s, "\\", "/", -1) |
| 193 | s = fileutil.DQEscapeString(s) |
| 194 | out, exitCode, err := execRead(wsl, name, "wslpath -u "+s) |
| 195 | if err != nil || exitCode != 0 { |
| 196 | errutil.ErrorRedPrintln("ERR: Failed to Path Translation") |
| 197 | fmt.Fprintf(os.Stderr, "ExitCode: 0x%x\n", int(exitCode)) |
| 198 | if err != nil { |
| 199 | return errutil.NewDisplayError(err, true, true, false) |
| 200 | } |
| 201 | return errutil.NewExitCodeError(int(exitCode), false) |
| 202 | } |
| 203 | convArgs = append(convArgs, out) |
| 204 | } else { |
| 205 | convArgs = append(convArgs, s) |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | return execute(wsl, name, convArgs) |
| 210 | } |
| 211 | |
| 212 | // executeNoArgs runs distro, but use terminal settings |
| 213 | func executeNoArgs(wsl wsllib.WslLib, reg wsllib.WslReg, name string, args []string) error { |