From 48e4eceb0ab69e3c4df7c1b09c4a852288fe20d0 Mon Sep 17 00:00:00 2001 From: 6543 Date: Wed, 1 Nov 2023 11:49:36 +0100 Subject: [PATCH] local backend make cmd log output similar to other shells (#2678) the cmd currently shows the full prompt and drop the exact error level. this set the prompt to be hidden and let cmd exit with error level reported by the command --- *Sponsored by Kithara Software GmbH* --- .vscode/settings.json | 2 +- pipeline/backend/local/command.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index c9b36b48b..40853bbdb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,5 @@ "eslint.workingDirectories": ["./web"], "prettier.configPath": "./web/.prettierrc.js", "prettier.ignorePath": "./web/.prettierignore", - "cSpell.words": ["Curr", "doublestar", "multierr"] + "cSpell.words": ["Curr", "doublestar", "ERRORLEVEL", "multierr"] } diff --git a/pipeline/backend/local/command.go b/pipeline/backend/local/command.go index e2b2a7eba..cfa36ad54 100644 --- a/pipeline/backend/local/command.go +++ b/pipeline/backend/local/command.go @@ -31,9 +31,11 @@ func genCmdByShell(shell string, cmds []string) (args []string, err error) { switch strings.TrimSuffix(strings.ToLower(shell), ".exe") { case "cmd": - script := "" + script := "@SET PROMPT=$\n" for _, cmd := range cmds { - script += fmt.Sprintf("%s || exit 1\n", cmd) + script += fmt.Sprintf("@echo + %s\n", strings.TrimSpace(shellescape.Quote(cmd))) + script += fmt.Sprintf("@%s\n", cmd) + script += "@IF NOT %ERRORLEVEL% == 0 exit %ERRORLEVEL%\n" } cmd, err := os.CreateTemp(os.TempDir(), "*.cmd") if err != nil {