Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for text/x-shellscript #28

Merged
merged 1 commit into from
Dec 1, 2020
Merged

Add support for text/x-shellscript #28

merged 1 commit into from
Dec 1, 2020

Conversation

ebkalderon
Copy link
Contributor

@ebkalderon ebkalderon commented Nov 29, 2020

Added

  • Add text::is_shellscript() matcher, adapted from how libmagic from file(1) detects shell scripts (source).
  • Add unit test which verifies that calling is_shellscript(b"#!") returns false.
  • Add integration test with sample.sh file.

Changed

  • Insert a new text/x-shellscript entry to MATCHER_MAP.

If we introduce support for other text formats which begin with #!, e.g. Python or Ruby or Perl scripts containing interpreter shebangs, we can always move this matcher lower in the MATCHER_MAP priority list.

This was inspired by how `libmagic` from `file(1)` detects shell
scripts, as seen here:

https://github.com/file/file/blob/e9bab11f6a4baebfa01e6a754d3f5263c93e8daa/magic/Magdir/varied.script

If we introduce support for other text formats which begin with `#!`,
e.g. Python or Ruby or Perl scripts with interpreter shebangs, we can
always move this matcher lower in the `MATCHER_MAP` priority list.
@bojand bojand merged commit c4e825f into bojand:master Dec 1, 2020
@bojand
Copy link
Owner

bojand commented Dec 1, 2020

Hello, thanks for the PR! Published in 0.3.2.

@ebkalderon
Copy link
Contributor Author

Thanks for the quick review and publish!

@ebkalderon ebkalderon deleted the add-x-shellscript-support branch December 1, 2020 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants