git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shawn Pearce <spearce@spearce.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH] Replace sed with perl when setting up perl scripts.
Date: Sat, 8 Jul 2006 15:37:17 -0400	[thread overview]
Message-ID: <20060708193717.GA17905@spearce.org> (raw)

next appears to be broken on MacOS X:

  INSTLIBDIR=`make -C perl -s --no-print-directory instlibdir` && \
  sed -e '1s|#!.*perl|#!/usr/bin/perl|1' \
      -e '2i\
          use lib (split(/:/, $ENV{GITPERLLIB} || '\'"$INSTLIBDIR"\''));' \
      -e 's|@@INSTLIBDIR@@|'"$INSTLIBDIR"'|g' \
      -e 's/@@GIT_VERSION@@/1.4.1.g659a/g' \
      git-archimport.perl >git-archimport+
  sed: 1: "2i use lib (split(/:/,  ...": command i expects \ followed by text
  make: *** [git-archimport] Error 1

I just spent half an hour messing around with the relevant Makefile
rule to try and get sed to be happy with this and I can't find the
magic necessary.  So I ported the sed to perl.  :-)

-->>-
Replace sed with perl when setting up perl scripts.

The sed magic to insert 'use lib' at the start of all
GIT Perl scripts wasn't working correctly on Mac OS X.
Replacing the sed invocations with perl invocations is
much more portable.

The replacement also has no negative impact on the build
as GIT cannot be compiled without the Git perl module,
which implies that perl is available and works.
---
 Makefile |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 8d429a0..e83d298 100644
--- a/Makefile
+++ b/Makefile
@@ -557,11 +557,12 @@ common-cmds.h: Documentation/git-*.txt
 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
 	rm -f $@ $@+
 	INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
-	sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|1' \
-	    -e '2i\
-	        use lib (split(/:/, $$ENV{GITPERLLIB} || '\'"$$INSTLIBDIR"\''));' \
-	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
-	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
+	$(PERL_PATH) -e '$$_=<>;print q{#!$(PERL_PATH_SQ)},qq{\n};' \
+	    -e 'print q{use lib (split(/:/, $$ENV{GITPERLLIB} || '\'"$$INSTLIBDIR"\''));},qq{\n};' \
+	    -e 'while(<>){' \
+	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g;' \
+	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g;' \
+	    -e 'print;}' \
 	    $@.perl >$@+
 	chmod +x $@+
 	mv $@+ $@
-- 
1.4.1.gc48f

             reply	other threads:[~2006-07-08 19:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-08 19:37 Shawn Pearce [this message]
2006-07-08 21:11 ` [PATCH] Replace sed with perl when setting up perl scripts Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060708193717.GA17905@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).