mcandre / stank

stank: analyzers for determining whether files smell like rotten POSIX shell scripts, or faintly rosy like Ruby and Python scripts
Other
52 stars 0 forks source link

funk: Optional strict max byte length rule for shebangs #92

Open mcandre opened 4 years ago

mcandre commented 4 years ago

Traditionally, shebang lines were limited to 16, 32, 127, 255, 1024, etc. bytes. For portability with very old systems, the user could specify a flag like maxShebangLength 16 to scan for additional warnings on long shebang lines.

https://web.archive.org/web/20170215070707/http://www.in-ulm.de/~mascheck/various/shebang/#details

I have no idea whether such constraints include newline terminators (nevermind carriage returns) in the calculation. Or whether the typical C-style null terminator is included in this calculation. The two #! appear to be part of the calculation. And these considerations are likely different between operating systems. Hence why this parameter is not in terms of glyphs, runes, characters. It's gotta be bytes for clarity and flexibility.

Any ASCII space (0x20) characters around the shebang command are included in the calculation, so make sure to NOT trim these as far as the max shebang length scan is concerned.