Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions puremagic/magic_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,19 @@
["23212f7573722f6c6f63616c2f62696e2f707974686f6e", 0, ".wsgi", "text/x-python", "Python script"],
["2321202f7573722f6c6f63616c2f62696e2f707974686f6e", 0, ".wsgi", "text/x-python", "Python script"],
["6576616c205c2265786563202f7573722f6c6f63616c2f62696e2f707974686f6e", 0, ".wsgi", "text/x-python", "Python script"],
["23212f62696e2f7368", 0, ".sh", "application/x-sh", "POSIX shell script"],
["2321202f62696e2f7368", 0, ".sh", "application/x-sh", "POSIX shell script"],
["23212f7573722f62696e2f7368", 0, ".sh", "application/x-sh", "POSIX shell script"],
["23212f7573722f62696e2f656e762073680a", 0, ".sh", "application/x-sh", "POSIX shell script"],
["23212f62696e2f64617368", 0, ".sh", "application/x-sh", "Dash shell script"],
["23212f62696e2f62617368", 0, ".sh", "application/x-shellscript", "Bash shell script"],
["2321202f62696e2f62617368", 0, ".sh", "application/x-shellscript", "Bash shell script"],
["23212f7573722f62696e2f62617368", 0, ".sh", "application/x-shellscript", "Bash shell script"],
["23212f7573722f62696e2f656e762062617368", 0, ".sh", "application/x-shellscript", "Bash shell script"],
["23212f7573722f6c6f63616c2f62696e2f62617368", 0, ".sh", "application/x-shellscript", "Bash shell script"],
["23212f62696e2f7a7368", 0, ".sh", "application/x-shellscript", "Zsh shell script"],
["23212f7573722f62696e2f7a7368", 0, ".sh", "application/x-shellscript", "Zsh shell script"],
["23212f7573722f62696e2f656e76207a73680a", 0, ".sh", "application/x-shellscript", "Zsh shell script"],
["53756d6d6172793a20", 0, ".spec", "text/x-rpm-spec", "RPM spec file"],
["25646566696e6520", 0, ".spec", "text/x-rpm-spec", "RPM spec file"],
["667479707174", 4, ".qtvr", "video/quicktime", "QuickTime video"],
Expand Down
12 changes: 12 additions & 0 deletions test/test_common_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,15 @@ def test_cfbf_msg():
assert ext == ".msg"
mime = puremagic.from_file(os.path.join(OFFICE_DIR, "test.msg"), mime=True)
assert mime == "application/vnd.ms-outlook"


def test_bash_shebang_detected():
"""Regression for #150: shell script shebangs identify as .sh, not .txt."""
bash = puremagic.from_stream(BytesIO(b"#!/bin/bash\necho hi\n"))
assert bash == ".sh"
sh = puremagic.from_stream(BytesIO(b"#!/bin/sh\necho hi\n"))
assert sh == ".sh"
env_bash = puremagic.from_stream(BytesIO(b"#!/usr/bin/env bash\necho hi\n"))
assert env_bash == ".sh"
zsh = puremagic.from_stream(BytesIO(b"#!/bin/zsh\necho hi\n"))
assert zsh == ".sh"