# [PATCH review] Build: make PERL_PATH = /usr/bin/env perl

7 messages from 2008-05-31 to 2008-06-02. Participants: Michael Witten, Junio C Hamano, Matthieu Moy, Steven Walter, David Christensen.
Thread: https://gitlist.dev/t/13743

## Michael Witten, 2008-05-31 18:34

Subject: [PATCH review] Build: make PERL_PATH = /usr/bin/env perl
Message-ID: <1212258886-87484-1-git-send-email-mfwitten@mit.edu>
URL: https://gitlist.dev/e/1212258886-87484-1-git-send-email-mfwitten%40mit.edu

```
This should make PERL_PATH more robust, as some
systems may have multiple version of perl installed.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 865e2bf..5828745 100644
--- a/Makefile
+++ b/Makefile
@@ -323,7 +323,7 @@ ifndef SHELL_PATH
 	SHELL_PATH = /bin/sh
 endif
 ifndef PERL_PATH
-	PERL_PATH = /usr/bin/perl
+	PERL_PATH = /usr/bin/env perl
 endif
 
 export PERL_PATH
-- 
1.5.5.GIT

```

## Junio C Hamano, 2008-05-31 19:55

Subject: Re: [PATCH review] Build: make PERL_PATH = /usr/bin/env perl
Message-ID: <7vabi6fdun.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vabi6fdun.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1212258886-87484-1-git-send-email-mfwitten@mit.edu>

```
Michael Witten <mfwitten@MIT.EDU> writes:

> This should make PERL_PATH more robust, as some
> systems may have multiple version of perl installed.
>
> Signed-off-by: Michael Witten <mfwitten@mit.edu>
> ---
>  Makefile |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 865e2bf..5828745 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -323,7 +323,7 @@ ifndef SHELL_PATH
>  	SHELL_PATH = /bin/sh
>  endif
>  ifndef PERL_PATH
> -	PERL_PATH = /usr/bin/perl
> +	PERL_PATH = /usr/bin/env perl
>  endif
>  
>  export PERL_PATH

If you insist, you can do so from your "make" command line, but I'd prefer
the default configuration as vanilla as possible.

I notice that both git-svn.perl and git-relink.perl begin with
"#!/usr/bin/env perl", and I think that is a mistake.  The #! line is
rewritten by Makefile, and there is no reason to write a "/usr/bin/env"
ugliness there in the source.  Not that it hurts, as it is blown away when
Makefile rewrites it to "#!$(PERL_PATH)", but it still looks ugly.

```

## Michael Witten, 2008-06-01 04:48

Subject: Re: [PATCH review] Build: make PERL_PATH = /usr/bin/env perl
Message-ID: <8F19F8D7-A9D3-41F5-9F64-1E955BC08DF0@mit.edu>
URL: https://gitlist.dev/e/8F19F8D7-A9D3-41F5-9F64-1E955BC08DF0%40mit.edu
In-Reply-To: <7vabi6fdun.fsf@gitster.siamese.dyndns.org>

```

On 31 May 2008, at 3:55 PM, Junio C Hamano wrote:

> If you insist, you can do so from your "make" command line, but I'd  
> prefer
> the default configuration as vanilla as possible.

The main trouble I've run into is with multiple versions of perl  
installed.
For instance, it is unadvisable to overwrite the Mac OS X provided perl
distribution. Consequently, custom installations are usually put into
/usr/local (also, MacPorts install everything into /opt/local).

This means that a 'vanilla' configuration may not (most likely will  
not) make
use of the perl distribution that is actually employed by the user.

This matters, because some tools like git-send-email require extra CPAN
modules such as Net::SMTP::SSL, which won't be found unless git has been
configured with a custom PERL_PATH.

It would seem to me that something like '/usr/bin/env perl' is slightly
more vanilla in the sense that it can handle more cases.

Perhaps the Makefile can be smarter about guessing the right path?

Sincerely,
Michael Witten

```

## Matthieu Moy, 2008-06-01 08:22

Subject: Re: [PATCH review] Build: make PERL_PATH = /usr/bin/env perl
Message-ID: <vpqabi5o992.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqabi5o992.fsf%40bauges.imag.fr
In-Reply-To: <1212258886-87484-1-git-send-email-mfwitten@mit.edu>

```
Michael Witten <mfwitten@MIT.EDU> writes:

> [problem with different versions of perl]

There's also the case where perl simply isn't available in /usr/bin,
but is somewhere else.

> It would seem to me that something like '/usr/bin/env perl' is slightly
> more vanilla in the sense that it can handle more cases.
>
> Perhaps the Makefile can be smarter about guessing the right path?

Perhaps something like this?

diff --git a/Makefile b/Makefile
index 865e2bf..5828745 100644
--- a/Makefile
+++ b/Makefile
@@ -323,7 +323,7 @@ ifndef SHELL_PATH
 	SHELL_PATH = /bin/sh
 endif
 ifndef PERL_PATH
-	PERL_PATH = /usr/bin/perl
+	PERL_PATH = $(shell which perl)
 endif
 
 export PERL_PATH

(untested)

This would generate the same files in the common case, but detect
another installation at compile time.

Note that this is indeed different from the original proposal in the
case of a multi-user system: here, the perl installation is chosen
once and for all by the guy who installs git, but can't be overridden
later (e.g by a user having his own custom perl installation in his
$HOME). I don't know which is better.


-- 
Matthieu

```

## Junio C Hamano, 2008-06-01 09:01

Subject: Re: [PATCH review] Build: make PERL_PATH = /usr/bin/env perl
Message-ID: <7vej7hbkal.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vej7hbkal.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <vpqabi5o992.fsf@bauges.imag.fr>

```
Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> Note that this is indeed different from the original proposal in the
> case of a multi-user system: here, the perl installation is chosen
> once and for all by the guy who installs git, but can't be overridden
> later (e.g by a user having his own custom perl installation in his
> $HOME). I don't know which is better.

"env" is Ok to make the same scripts you have privately in your $HOME/bin/
(which is mounted across different platforms) work with perl or python or
whatever from different places, but it is very unsuitable for scripts that
are meant to be installed per machine, such as ours, for use by many
people.

If you do not have (or want to use) common programs at usual place, you
tell "make" where they are, and the resulting scripts will use the same
program for everybody.  That way, you don't have to worry about confusing
people by having scripts use different perl depending on who they are, and
by failing for some people and working for others.

You _can_ use "/usr/bin/env" for your own build and I won't stop you, but
please don't tell me to ship such ugliness in the default Makefile.  We
will not do SHELL_PATH = $(shell which sh) either, ever.

By the way, "which" is probably Ok when you know there _is_ an instance of
the program somewhere on the $PATH, but be careful if you suspect there
might not be any.  Depending on whose "which" it is, it may not exit with
non-zero status nor be silent on the standard output.  If you are shooting
for portability, don't use it in your scripts, ever.  Also "type" is not
much better either ("type -p" is a bash-ism).

Probably the closest to the most portable would be "command -v"; this is a
POSIXly kosher way and seems to be Ok with /bin/ksh and OpenBSD /bin/sh as
well, not just bash and dash.

```

## Steven Walter, 2008-06-01 18:11

Subject: Re: [PATCH review] Build: make PERL_PATH = /usr/bin/env perl
Message-ID: <e06498070806011111w792399dfi9dad780ee00faa8a@mail.gmail.com>
URL: https://gitlist.dev/e/e06498070806011111w792399dfi9dad780ee00faa8a%40mail.gmail.com
In-Reply-To: <1212258886-87484-1-git-send-email-mfwitten@mit.edu>

```
On Sat, May 31, 2008 at 2:34 PM, Michael Witten <mfwitten@mit.edu> wrote:
> This should make PERL_PATH more robust, as some
> systems may have multiple version of perl installed.
>
> Signed-off-by: Michael Witten <mfwitten@mit.edu>
> ---
>  Makefile |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 865e2bf..5828745 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -323,7 +323,7 @@ ifndef SHELL_PATH
>        SHELL_PATH = /bin/sh
>  endif
>  ifndef PERL_PATH
> -       PERL_PATH = /usr/bin/perl
> +       PERL_PATH = /usr/bin/env perl
>  endif
>
>  export PERL_PATH
> --
> 1.5.5.GIT

If you do this, you will have to modify the perl scripts to remove the
-w flag from their hash-bang line.  "/usr/bin/env perl -w" does not
seem to do the expected thing.
-- 
-Steven Walter <stevenrwalter@gmail.com>
"A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects."
 -Robert Heinlein

```

## David Christensen, 2008-06-02 02:17

Subject: Re: [PATCH review] Build: make PERL_PATH = /usr/bin/env perl
Message-ID: <84422837-A45A-4B33-9D25-8053477CD164@endpoint.com>
URL: https://gitlist.dev/e/84422837-A45A-4B33-9D25-8053477CD164%40endpoint.com
In-Reply-To: <e06498070806011111w792399dfi9dad780ee00faa8a@mail.gmail.com>

```
> If you do this, you will have to modify the perl scripts to remove the
> -w flag from their hash-bang line.  "/usr/bin/env perl -w" does not
> seem to do the expected thing.

Insofar as compatibility is concerned, perl's -w flag is equivalent  
to the 'use warnings' language pragma, which has been supported since  
5.6 (circa 2000).  Seeing as perl's Unicode support did not really  
mature until 5.8, I imagine that adding the 'use warnings' pragma and  
doing away with the -w flag would be a reasonable approach to take.

Regards,

David
--
David Christensen
End Point Corporation
david@endpoint.com

```
