colis-anr / morbig

A static parser for POSIX Shell
Other
190 stars 8 forks source link

Feature Request: recognition of shebangs #192

Open anadon opened 1 week ago

anadon commented 1 week ago

Recognizing shebangs ( #!/usr/bin/sh or #! /usr/bin/env sh or similar ) can be used with a word splitting pattern match to make sure to match the shell being invoked is supported by Morbig.

Niols commented 1 week ago

This is indeed a good idea. There is the --skip-nosh flag that does something similar, but not quite what you are looking for. It looks pretty ad-hoc anyways, so it would make sense to replace it by a better way to declare how one wants to handle shebangs.

anadon commented 1 week ago

If you could point me in the right direction, I'll try to take it from there.

Niols commented 1 week ago

I wasn't the instigator of the --skip-nosh option, but I would say the best start is to look how it is implemented. As a first idea, I would say that we probably need two options, one to say how to reject files (the current --skip-nosh option and what you suggest) and one to say what to do to rejected files (skip or fail, I suppose). Maybe:

(I'm not very good at naming, so feel free to suggest other things!)