Thread (15 messages) flat view 15 messages, 4 authors, 2018-03-19

Re: [PATCH v6 2/3] Makefile: add Perl runtime prefix support

From: Daniel Jacques <hidden>
Date: 2018-03-19 19:47:44

On Mon, Mar 19, 2018 at 3:21 PM Ævar Arnfjörð Bjarmason [off-list ref]
wrote:
I think it would be more idiomatic and more paranoid (we'll catch bugs)
to do:
      my $exec_path;
      if (exists $ENV{GIT_EXEC_PATH}) {
          $exec_path = $ENV{GIT_EXEC_PATH};
      } else {
          [...]
      }
I.e. we're interested if we got passed GIT_EXEC_PATH, so let's see if it
exists in the env hash, and then use it as-is. If we have some bug where
it's an empty string we'd like to know, presumably...
Good idea, done.
quoted
+
+     # Trim off the relative gitexecdir path to get the system path.
+     (my $prefix = $exec_path) =~ s=${gitexecdir_relative}$==;
The path could contain regex metacharacters, so let's quote those via:
      (my $prefix = $exec_path) =~ s/\Q$gitexecdir_relative\E$//;
This also nicely gets us rid of the more verbose ${} form, which makes
esnse when we're doing ${foo}$ instead of the arguably less readbale
$foo$, but when it's \Q$foo\E$ it's clear what's going on.
Ah cool - makes sense. I'm not strong with Perl, so I wasn't aware that
this was an option, but I agree it's cleaner. Done.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help