diff options
| -rw-r--r-- | runner/shell/shell.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/runner/shell/shell.go b/runner/shell/shell.go index 39fdf79..f696a46 100644 --- a/runner/shell/shell.go +++ b/runner/shell/shell.go @@ -110,8 +110,6 @@ func (s *shell) CreateTarget(fs fs.FS, src string, file string, _ fs.DirEntry) ( func (s *shell) ShellFor(fs fs.FS, file string) (string, error) { - var shell, shebang string - // low-hanging fruit - indicative filename if byFile := s.ShellByFilename(file); byFile != "" { return byFile, nil @@ -126,21 +124,21 @@ func (s *shell) ShellFor(fs fs.FS, file string) (string, error) { if !scanner.Scan() { return "", NoContentError } - txt := scanner.Text() - if strings.HasPrefix(txt, "#!") { + firstLine := scanner.Text() + if strings.HasPrefix(firstLine, "#!") { // shebang found - byShebang := s.ShellByShebang(txt) + byShebang := s.ShellByShebang(firstLine) if byShebang != "" { return byShebang, nil } else { - _, _ = spool.Warn("script has %s but could not find %s\n", shebang) + _, _ = spool.Warn("script has %s but could not find %s\n", firstLine) } } // if no shebang, just send the first one we find for _, s := range Shells { if p, err := exec.LookPath(s); err != nil { - shell = p + return p, nil } } |
