From bf687ea7e4aac59d6a5086a79500e0dd735b1aea Mon Sep 17 00:00:00 2001 From: windvalley Date: Wed, 29 May 2024 11:28:25 +0800 Subject: [PATCH] fix: fix issue #37 Fixes #37 --- pkg/batchssh/batchssh.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/batchssh/batchssh.go b/pkg/batchssh/batchssh.go index e9dba51..92ef87d 100644 --- a/pkg/batchssh/batchssh.go +++ b/pkg/batchssh/batchssh.go @@ -237,11 +237,11 @@ func (c *Client) ExecuteScript( command := "" switch { case sudo && remove: - command = fmt.Sprintf("%ssudo -u %s -H bash -c '%s;rm -f %s'", exportLang, runAs, script, script) + command = fmt.Sprintf("%ssudo -u %s -H bash -c '%s;rc=$?;rm -f %s;exit $rc'", exportLang, runAs, script, script) case sudo && !remove: command = fmt.Sprintf("%ssudo -u %s -H bash -c '%s'", exportLang, runAs, script) case !sudo && remove: - command = fmt.Sprintf("%s%s;rm -f %s", exportLang, script, script) + command = fmt.Sprintf("%s%s;rc=$?;rm -f %s;exit $rc", exportLang, script, script) case !sudo && !remove: command = exportLang + script }