From 081695e47ada143231e93356e8201f9bb9bb22e0 Mon Sep 17 00:00:00 2001 From: Chris Koch Date: Mon, 4 Mar 2024 19:20:31 +0000 Subject: [PATCH] gosh: stop running scripts if they end with .sh Not a good way to figure out how to run something. Filed https://github.com/mvdan/sh/issues/1065 instead. Signed-off-by: Chris Koch --- cmds/core/gosh/completer.go | 12 ------------ cmds/core/gosh/completer_liner.go | 12 ------------ 2 files changed, 24 deletions(-) diff --git a/cmds/core/gosh/completer.go b/cmds/core/gosh/completer.go index 0552c6d439..ddd2dbffff 100644 --- a/cmds/core/gosh/completer.go +++ b/cmds/core/gosh/completer.go @@ -142,16 +142,6 @@ func runInteractive(runner *interp.Runner, parser *syntax.Parser, stdout, stderr default: } - // check if we want to execute a shell script - fields := strings.Fields(line) - if len(fields) > 0 && strings.HasSuffix(fields[0], "sh") { - if err := runScript(runner, parser, fields[0]); err != nil { - fmt.Fprintf(stderr, "error: %s\n", err.Error()) - } - - continue - } - if line != "" { if err := input.AddHistory(line); err != nil { fmt.Fprintf(stdout, "unable to add %s to history: %v\n", line, err) @@ -161,12 +151,10 @@ func runInteractive(runner *interp.Runner, parser *syntax.Parser, stdout, stderr if err := parser.Stmts(strings.NewReader(line), func(stmt *syntax.Stmt) bool { if parser.Incomplete() { fmt.Fprintf(stdout, "-> ") - return true } runErr = runner.Run(context.Background(), stmt) - return !runner.Exited() }); err != nil { fmt.Fprintf(stderr, "error: %s\n", err.Error()) diff --git a/cmds/core/gosh/completer_liner.go b/cmds/core/gosh/completer_liner.go index 650261b6b7..d6339a0cab 100644 --- a/cmds/core/gosh/completer_liner.go +++ b/cmds/core/gosh/completer_liner.go @@ -82,16 +82,6 @@ func runInteractive(runner *interp.Runner, parser *syntax.Parser, stdout, stderr default: } - // check if we want to execute a shell script - fields := strings.Fields(line) - if len(fields) > 0 && strings.HasSuffix(fields[0], "sh") { - if err := runScript(runner, parser, fields[0]); err != nil { - fmt.Fprintf(stderr, "error: %s\n", err.Error()) - } - - continue - } - if line != "" { input.AppendHistory(line) if f != nil { @@ -101,12 +91,10 @@ func runInteractive(runner *interp.Runner, parser *syntax.Parser, stdout, stderr if err := parser.Stmts(strings.NewReader(line), func(stmt *syntax.Stmt) bool { if parser.Incomplete() { fmt.Fprintf(stdout, "-> ") - return true } runErr = runner.Run(context.Background(), stmt) - return !runner.Exited() }); err != nil { fmt.Fprintf(stderr, "error: %s\n", err.Error())