[Koha-devel] Inconsistent Perl shebangs (new coding guideline?)

dcook at prosentient.com.au dcook at prosentient.com.au
Tue Oct 13 01:19:29 CEST 2020


Hi all,

 

I was looking at "Bug 20582 - Turn Koha into a Mojolicious application" when
I noticed that some of the scripts were using "#!/usr/bin/env perl" instead
of "#!/usr/bin/perl". While there is no requirement in the Coding Guidelines
to use "#!/usr/bin/perl", I thought it would be best for all our Perl
scripts to be consistent.

 

However, now I'm weighing up the options.

 

Conceptually, using "#!/usr/bin/env perl" means that we can use
perlbrew/plenv (or manually provide a different Perl in our $PATH) when
running these scripts, so that we don't have to use the system Perl located
at /usr/bin/perl. 

 

That said, I was concerned about how most CGI scripts have "#!/usr/bin/perl"
in them and the implications that might have if we invoked
Starman/Morbo/Hypnotoad with a different Perl, but looking at
Plack::App::CGIBin, CGI::Emulate::PSGI, Plack::App::WrapCGI, CGI::Compile,
and Koha::App::Plugin::CGIBinKoha makes me think that the shebang in CGI
scripts is ignored when using these Perl application servers, since they're
just read as Perl code and not handed to the exec() family of kernel
syscalls. 

 

Starman/Morbo/Hypnotoad have been installed with /usr/bin/perl shebangs, so
they'll use the system Perl by default, but I think if they were installed
using plenv and Carton for instance that they'd have their shebangs
rewritten appropriately. We could also invoke Starman/Morbo/Hypnotoad with
the version of Perl that we desire. 

 

So ultimately. I suppose the most reasonable thing to do is probably to
mandate "#!/usr/bin/perl" for all Koha Perl scripts? If someone does want to
use a different Perl, I suppose the onus is on them to make sure they
execute Koha Perl scripts with a different Perl binary? 

 

Also, do people think there is a point in repairing existing Koha Perl
scripts that have '#!/usr/bin/env perl' instead of '#!/usr/bin/perl'?

 

Cheers,

 

David Cook

Software Engineer

Prosentient Systems

72/330 Wattle St

Ultimo, NSW 2007

Australia

 

Office: 02 9212 0899

Online: 02 8005 0595

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20201013/785888ce/attachment.htm>


More information about the Koha-devel mailing list