diff options
| author | Jeff Carr <[email protected]> | 2025-10-03 02:47:40 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-03 02:47:40 -0500 |
| commit | bdb6a5570525ae59f21a277f50e5a2dcd86e9dd0 (patch) | |
| tree | 2bd12a44fef47b712ce6be9ba529dea612b0905f /exit.go | |
| parent | d0a5983ade20fed877c2803b73528c28dac77fa6 (diff) | |
moving stuff here from what was bash before
Diffstat (limited to 'exit.go')
| -rw-r--r-- | exit.go | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -0,0 +1,50 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "fmt" + "os" + + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +// exits if not root +func checkSuperuser() { + if os.Getuid() != 0 { + badExit(fmt.Errorf("you must be root")) + } +} + +func exitOnError(cmd []string) { + var err error + log.Info("Running:", cmd) + _, err = shell.RunVerbose(cmd) + if err != nil { + badExit(err) + } +} + +func exitOnErrorRealtime(cmd []string) { + var err error + log.Info("Running:", cmd) + _, err = shell.RunRealtimeError(cmd) + if err != nil { + badExit(err) + } +} + +func okExit(thing string) { + if thing != "" { + log.Info(thing, "ok") + } + // log.Info("Finished go-clean on", check.GetGoPath(), "ok") + os.Exit(0) +} + +func badExit(err error) { + log.Info("wit failed: ", err) + os.Exit(-1) +} |
