aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Unportable perl invocation  (Read 3412 times)

Nodsu

  • Jr. Member
  • **
  • Karma: 3
  • Offline Offline
  • Posts: 62
Unportable perl invocation
« on: December 20, 2007, 08:32:57 PM »

file_generator.pl uses a hashbang line that assumes perl executable in /usr/bin. This is not very portable.
A nicer approach would be to use "#!/usr/bin/env perl"
Logged

lfroen

  • Guest
Re: Unportable perl invocation
« Reply #1 on: December 23, 2007, 03:38:46 PM »

And why is that better, can you tell?
Logged

skolnick

  • Global Moderator
  • Hero Member
  • *****
  • Karma: 24
  • Offline Offline
  • Posts: 1188
  • CentOS 6 User
Re: Unportable perl invocation
« Reply #2 on: December 23, 2007, 07:35:40 PM »

Nodsu, could you please tell us which platform does /usr/bin/perl not work? I have only access to linux and solaris, and both approaches would work equally well on both, so I fail to see the difference,just like lfroen pointed. Is there some standard saying that env will always be in /usr/bin?

Regards.
Logged

Nodsu

  • Jr. Member
  • **
  • Karma: 3
  • Offline Offline
  • Posts: 62
Re: Unportable perl invocation
« Reply #3 on: December 25, 2007, 05:37:51 PM »

FreeBSD and NetBSD for example put their packages in /usr/local and /usr/pkg. Also, it will be /usr/local/bin/perl in any unix OS where you have to build Perl manually. And we can imagine a system where a user wants to use her own Perl installation (in /home or wherever) opposed to the systemwide perl (in /usr/bin).

As for why the env command is better, it executes perl according to the PATH variable instead of a hardcoded path. Env is POSIX, so it shold be present in every decent unix OS.
Logged

Vollstrecker

  • Administrator
  • Hero Member
  • *****
  • Karma: 67
  • Offline Offline
  • Posts: 1550
  • Unofficial Debian Packager
    • http://vollstreckernet.de
Re: Unportable perl invocation
« Reply #4 on: December 25, 2007, 05:52:33 PM »

Beside the fact that you can't state that env will always be found in /usr/bin (at least after your statement about the users own perl) there would be the only way to use an option in configure and invoke the script with ${perl-location} script.pl. If that is what you want, what's next? sed, awk or one the many other tools amule's configure-script  uses to work?
Logged
Homefucking is killing prostitution

Nodsu

  • Jr. Member
  • **
  • Karma: 3
  • Offline Offline
  • Posts: 62
Re: Unportable perl invocation
« Reply #5 on: December 26, 2007, 01:48:22 PM »

Yes indeed, a proper configure script should check for all dependencies and caution the user when they are not found.

This perl thing is a real world issue I ran into. sed and awk are a bit far fetched. sed and env are POSIX and already included in every decent unix and located in /usr/bin. Configure already checks for awk location (your fault if you are not using the configure-provided location).
Logged

skolnick

  • Global Moderator
  • Hero Member
  • *****
  • Karma: 24
  • Offline Offline
  • Posts: 1188
  • CentOS 6 User
Re: Unportable perl invocation
« Reply #6 on: December 27, 2007, 12:59:32 AM »

Yes indeed, a proper configure script should check for all dependencies and caution the user when they are not found.

This perl thing is a real world issue I ran into. sed and awk are a bit far fetched. sed and env are POSIX and already included in every decent unix and located in /usr/bin. Configure already checks for awk location (your fault if you are not using the configure-provided location).
sed is an issue in solaris (for example) because aMule requires GNU sed to compile properly, the POSIX one included with solaris will not work. It's the same for the shell in soe scripts, where bash is required, and the /bin/sh in solaris will not work.

Regards.
Logged