shebang scan regex fix
^ means "beginning of line" in emacs lisp regexp, not "beginning of buffer". So use ``` instead.
Some users have a habit of writing description of a program(using comments) before the shebang line. So I thought why not scan entire buffer for 'shebang line' including first line. If not mistaken, your patch will only scan the very first line of visiting buffer.
Any suggestions are most welcome. Thanks for spending some time on 'insert-shebang' .
My English is not good, please excuse me for any mistake :-)
But if there are other comments (even whitespace) before the shebang line, the shebang line just won't work, because the kernel's program loader only checks first two bytes (the "Magic number") of a file. In other words, a shebang line not in the very beginning of a file is not "shebang line" anymore. Details in http://en.wikipedia.org/wiki/Shebang_%28Unix%29.
Some shell script may invoke other interpreter, and save the content (which may contain a "shebang line") to be interpreted in the same shell script as Heredoc. In this case, scanning entire buffer may cause incorrect result. Perl/Ruby's DATA section may cause the same problem, such as this script.
Hi Dewdrops, 'insert-shebang' can safely handle comments before or after shebang-line, so this should not be an issue. Regarding 'white spaces' and shell script invoking other interpreter, I need to come up with some logical flow. Thanks for pointing this out. If you have any suggestion, feel free to reply.
All right. Though I still think shebang line should be the very first line.
Thanks for this plugin and (quick) response. :-)
I'll keep this issue open until I get some good fix.
Thanks again.
On Fri, May 9, 2014 at 4:37 PM, Dewdrops [email protected] wrote:
All right. Though I still think shebang line should be the very first line.
Thanks for this plugin and (quick) response. :-)
— Reply to this email directly or view it on GitHubhttps://github.com/psachin/insert-shebang/pull/9#issuecomment-42655088 .
Sachin