return non-zero exit code on container sub-commands

Signed-off-by: xu yang <xyang@ciq.com>
This commit is contained in:
xu yang
2024-09-25 08:50:50 +00:00
parent f73832c337
commit 94e203dd2e
8 changed files with 23 additions and 56 deletions

View File

@@ -4,6 +4,7 @@
package shell
import (
"fmt"
"os"
"path"
@@ -19,13 +20,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var allargs []string
if !container.ValidSource(containerName) {
wwlog.Error("Unknown Warewulf container: %s", containerName)
os.Exit(1)
return fmt.Errorf("unknown Warewulf container: %s", containerName)
}
shellName := os.Getenv("SHELL")
if !container.ValidSource(containerName) {
wwlog.Error("Unknown Warewulf container: %s", containerName)
os.Exit(1)
return fmt.Errorf("unknown Warewulf container: %s", containerName)
}
var shells []string
if shellName == "" {