I vaguely remember I had this discussion with someone, somewhere. And I have been told it was not a good idea. But I cannot remember why, who, where... Le mar. 13 oct. 2020 à 01:19, <dcook@prosentient.com.au> a écrit :
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
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/