diff options
| author | ewy <ewy0@protonmail.com> | 2026-11-21 15:31:02 +0100 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-11-21 15:31:02 +0100 |
| commit | 9f023f5cd9188c343d3b015f3439b34dea715b6a (patch) | |
| tree | ab8f4b6f1ea879983393bdb039d2a4c126a57c17 | |
| parent | 033bd9d11dd1b9b3fe9171b07747611ee0068af5 (diff) | |
warning message for scripts without shebang
| -rw-r--r-- | indexers/pikdex/index.go | 2 | ||||
| -rw-r--r-- | runner/shell/shell.go | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/indexers/pikdex/index.go b/indexers/pikdex/index.go index e5d4405..248e1fc 100644 --- a/indexers/pikdex/index.go +++ b/indexers/pikdex/index.go @@ -91,7 +91,7 @@ func (u *pikdex) Index(absPath string, f fs.FS, runners []model.Runner) ([]model for _, r := range runners { wants, err := r.Wants(f, p, d) if err != nil { - _, _ = spool.Warn("%v\n", err) + _, _ = spool.Warn("%s/%s: %v\n", absPath, p, err) } if wants { t, err := r.CreateTarget(f, absPath, p, d) diff --git a/runner/shell/shell.go b/runner/shell/shell.go index f696a46..6c9a1ed 100644 --- a/runner/shell/shell.go +++ b/runner/shell/shell.go @@ -23,6 +23,7 @@ var NoShellError = errors.New("could not find any shell interpreters") var ExtShellMap = map[string]string{ ".bash": "bash", + ".zsh": "zsh", ".fish": "fish", ".ps1": "powershell", ".bat": "cmd", @@ -39,6 +40,8 @@ type shell struct { Locations map[string]string } +var AmbiguousScriptError = errors.New("ambiguous script without shebang\nadd first line #!/usr/bin/env bash") + func (s *shell) Wants(f fs.FS, file string, entry fs.DirEntry) (bool, error) { if entry != nil && entry.IsDir() { return false, nil @@ -62,6 +65,9 @@ func (s *shell) Wants(f fs.FS, file string, entry fs.DirEntry) (bool, error) { return true, nil } } + if filepath.Ext(file) == ".sh" { + return true, AmbiguousScriptError + } return false, nil } |
