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

shebang scan regex fix #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Dewdrops
Copy link

@Dewdrops Dewdrops commented May 9, 2014

^ means "beginning of line" in emacs lisp regexp, not "beginning of buffer". So use ``` instead.

@psachin
Copy link
Owner

psachin commented May 9, 2014

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' .

@Dewdrops
Copy link
Author

Dewdrops commented May 9, 2014

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.

@psachin
Copy link
Owner

psachin commented May 9, 2014

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.

@Dewdrops
Copy link
Author

Dewdrops commented May 9, 2014

All right. Though I still think shebang line should be the very first line.

Thanks for this plugin and (quick) response. :-)

@psachin
Copy link
Owner

psachin commented May 9, 2014

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//pull/9#issuecomment-42655088
.

Sachin

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