Skip to content

Change shebang to /usr/bin/env/perl#847

Merged
brucemiller merged 2 commits into
brucemiller:masterfrom
tkw1536:shebang-fix
Jul 13, 2017
Merged

Change shebang to /usr/bin/env/perl#847
brucemiller merged 2 commits into
brucemiller:masterfrom
tkw1536:shebang-fix

Conversation

@tkw1536

@tkw1536 tkw1536 commented Jul 8, 2017

Copy link
Copy Markdown
Contributor

On certain machines, when run directly, all scripts would default to use
the perl interpreter located in /usr/bin. This can cause problems on
machines where perl is located in a different path, or where multiple
perl instances are present on a system (such as on Mac when using
homebrew).

This PR updates the shebang, the line which starting with #!
indicating the interpreter to use when running a file, from
/usr/bin/perl to /usr/bin/env perl. This makes sure not to hard-code the
perl path to /usr/bin, but to instead search $PATH for the appropriate
file.

On certain machines, when run directly, all scripts would default to use
the perl interpreter located in /usr/bin. This can cause problems on
machines where perl is located in a different path, or where multiple
perl instances are present on a system (such as on Mac when using
homebrew).

This commit updates the shebang, the line which starting with #!
indicating the interpreter to use when running a file, from
/usr/bin/perl to /usr/bin/env perl. This makes sure not to hard-code the
perl path to /usr/bin, but to instead search $PATH for the appropriate
file.
@brucemiller

brucemiller commented Jul 8, 2017 via email

Copy link
Copy Markdown
Owner

@dginev

dginev commented Jul 8, 2017

Copy link
Copy Markdown
Collaborator

Tom's change looks to be the best practice:
http://perldoc.perl.org/perlrun.html

But why did travis fail?

@dginev

dginev commented Jul 8, 2017

Copy link
Copy Markdown
Collaborator

Travis failed because the env form does not allow passing arguments, such as -w to the interpreter. And there are trade-offs it seems:
https://unix.stackexchange.com/a/29620

@dginev

dginev commented Jul 8, 2017

Copy link
Copy Markdown
Collaborator

As can be seen in the wisdom in the unix stackexchange comment i shared, the -w can be upgraded to an explicit use warnings; in each of the executables, which solves the travis failure. Personally I am happy either way, I have used both forms in the past and my setups are simple ("standard"?) enough to work with either form.

@tkw1536

tkw1536 commented Jul 8, 2017 via email

Copy link
Copy Markdown
Contributor Author

It turns out that some /usr/bin/env implementations do not support
passing parameters to the interporeter. This caused problems, in
particular causing the Travis Tests to fail.

After a suggestion from @dginev, this commit fixes the issue by removing
the -w flag from all shebang lines and instead adding a 'use warnings;'
where neccessary.
@brucemiller brucemiller merged commit 8801a10 into brucemiller:master Jul 13, 2017
@tkw1536 tkw1536 deleted the shebang-fix branch July 13, 2017 19:24
@brucemiller

Copy link
Copy Markdown
Owner

For the record, there is a slight downside to this: If you run valgrind on latexml, it no longer "sees" perl, but (apparently) checks the memory usage of env(?). The easy workaround is

valgrind perl path/to/latexml ...

Just so you know...

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.

3 participants