summaryrefslogtreecommitdiff
path: root/shell.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2019-06-06 15:59:49 -0700
committerJeff Carr <[email protected]>2019-06-06 15:59:49 -0700
commitf59e1b1f8403216d435e4904550eb6c2844ce690 (patch)
treefbee32ba3e521b82de8ad4a6722cf6155445bf72 /shell.go
parentd7a665031c8f95eb6c96bbdc642fe3ab74e851cf (diff)
add perl 'chomp'. too lazy to make it correct with regex
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'shell.go')
-rw-r--r--shell.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/shell.go b/shell.go
index aaad099..ddc9a1f 100644
--- a/shell.go
+++ b/shell.go
@@ -44,7 +44,7 @@ func Script(cmds string) int {
lines := strings.Split(strings.Replace(cmds, "\r\n", "\n", -1), "\n")
for _, line := range lines {
- line = strings.TrimSpace(line) // this is like 'chomp' in perl
+ line = Chomp(line) // this is like 'chomp' in perl
log.Println("LINE:", line)
time.Sleep(1)
Run(line)
@@ -79,7 +79,7 @@ func SetStderr(newerr *os.File) {
func Run(cmdline string) string {
log.Println("shell.Run() START " + cmdline)
- cmd := strings.TrimSpace(cmdline) // this is like 'chomp' in perl
+ cmd := Chomp(cmdline) // this is like 'chomp' in perl
cmdArgs := strings.Fields(cmd)
if (len(cmdArgs) == 0) {
callback(fmt.Errorf("cmdline == ''"), 0)
@@ -191,7 +191,7 @@ func Run(cmdline string) string {
log.Println("shell.Run() END ", cmdline)
log.Println("shell.Run() calling callback() :")
callback(fmt.Errorf("no error"), 0)
- return string(b)
+ return Chomp(b)
}
func Daemon(cmdline string, timeout time.Duration) int {