From 3eba90e3520b029692fa506b3a46459fb602a320 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 8 Oct 2024 17:20:51 -0400 Subject: [PATCH] use the same old janky shell script logic that once worked --- pkg/programkind/programkind.go | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/pkg/programkind/programkind.go b/pkg/programkind/programkind.go index 39bb28890..211f3de75 100644 --- a/pkg/programkind/programkind.go +++ b/pkg/programkind/programkind.go @@ -55,7 +55,7 @@ var supportedKind = map[string]string{ "pyc": "application/x-python-code", "rb": "text/x-ruby", "rs": "text/x-rust", - "script": "text/x-script", + "script": "text/x-generic-script", "scpt": "application/x-applescript", "scptd": "application/x-applescript", "service": "text/x-systemd", @@ -106,7 +106,7 @@ func File(path string) (*FileType, error) { return mtype, nil } - // read hdr content for future strategies + // read hdr s for future strategies var hdr [32]byte f, err := os.Open(path) if err != nil { @@ -120,24 +120,27 @@ func File(path string) (*FileType, error) { } // final strategy: DIY matching where mimetype is too strict. - content := string(hdr[:]) + s := string(hdr[:]) switch { case hdr[0] == '\x7f' && hdr[1] == 'E' || hdr[2] == 'L' || hdr[3] == 'F': return Path(".elf"), nil - case strings.HasPrefix(content, "#!/bin/sh"): - return Path(".sh"), nil - case strings.HasPrefix(content, "#!/bin/bash"): - return Path(".bash"), nil - case strings.Contains(content, "