git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] perl/Makefile: handle paths with spaces in the NO_PERL_MAKEMAKER section

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Aug 7, 2008, 00:23 UTC
Message-ID
<lWtENUxH2rUuPeH6fGlmuHzUPOVM2GJNQWM361G7sj6Za8Qm8qm3Wg@cipher.nrlssc.navy.mil>
In-Reply-To
<1JOFfIWYHgmUErPhpB6xWtV5uZYv3_v3tBnt928x644O-1AquEzzIA@cipher.nrlssc.navy.mil>
Brandon Casey wrote:
Show 18 quoted lines
> Junio C Hamano wrote:
>> Brandon Casey <casey@nrlssc.navy.mil> writes:
>>
>>> There are problems here with spaces, single quotes, and double quotes.
>>> I'll follow up in another email.
>> I guess we've opened up a large can of worms.  Let's have the minimum fix
>> that says "We do support whitespace in these paths but no other funnies"
>> and leave the more intrusive one for post 1.6.0, for now.
> 
> I think those two patches I just sent are enough.
> 
> You can apply the double-quote escaping patch I sent earlier if you want
> (the one that escapes double quotes in the macros compiled in c programs).
> But we'd have a problem installing the perl scripts using MakeMaker, and
> we'd have a problem _running_ the perl scripts since the single double
> quote causes a syntax error in the perl script. Let's wait till someone
> wants to have " in their path shows up (and let them figure out how to
> fix it).

ok, here's a patch that allows me to compile, install using MakeMaker, and actually use the perl scripts generated by the make file when the installation prefix contains odd characters like double quote, single quote, space or semi-colon. The patch below includes that patch I mentioned about escaping double quotes for c macros.

-brandon
--->8---
diff --git a/Makefile b/Makefile
index 0d373f7..21241b4 100644
--- a/Makefile
+++ b/Makefile
@@ -1031,15 +1031,15 @@ endif
 # Shell quote (do not use $(call) to accommodate ancient setups);
 
 SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
-ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
+ETC_GITCONFIG_SQ = $(subst ",\",$(subst ','\'',$(ETC_GITCONFIG)))
 
 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
 bindir_SQ = $(subst ','\'',$(bindir))
-mandir_SQ = $(subst ','\'',$(mandir))
-infodir_SQ = $(subst ','\'',$(infodir))
-gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
-template_dir_SQ = $(subst ','\'',$(template_dir))
-htmldir_SQ = $(subst ','\'',$(htmldir))
+mandir_SQ = $(subst ",\",$(subst ','\'',$(mandir)))
+infodir_SQ = $(subst ",\",$(subst ','\'',$(infodir)))
+gitexecdir_SQ = $(subst ",\",$(subst ','\'',$(gitexecdir)))
+template_dir_SQ = $(subst ",\",$(subst ','\'',$(template_dir)))
+htmldir_SQ = $(subst ",\",$(subst ','\'',$(htmldir)))
 prefix_SQ = $(subst ','\'',$(prefix))
 
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
@@ -1116,11 +1116,11 @@ perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
 
 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
 	$(QUIET_GEN)$(RM) $@ $@+ && \
-	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
+	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir | sed -e 's/"/\\\\\\\"/g'` && \
 	sed -e '1{' \
 	    -e '	s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 	    -e '	h' \
-	    -e '	s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
+	    -e '	s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || q"@@INSTLIBDIR@@"));=' \
 	    -e '	H' \
 	    -e '	x' \
 	    -e '}' \
@@ -1134,7 +1134,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
 	$(QUIET_GEN)$(RM) $@ $@+ && \
 	sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 	    -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
-	    -e 's|++GIT_BINDIR++|$(bindir)|g' \
+	    -e 's|++GIT_BINDIR++|$(subst ",\\",$(bindir_SQ))|g' \
 	    -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
 	    -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
 	    -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 90cd99b..155b1ac 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -29,7 +29,7 @@ our $my_uri = $cgi->url(-absolute => 1);
 
 # core git executable to use
 # this can just be "git" if your webserver has a sensible PATH
-our $GIT = "++GIT_BINDIR++/git";
+our $GIT = q"++GIT_BINDIR++/git";
 
 # absolute fs-path which will be prepended to the project path
 #our $projectroot = "/pub/scm";
diff --git a/perl/Makefile b/perl/Makefile
index dcbd2dd..2597d60 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -39,7 +39,7 @@ $(makfile): ../GIT-CFLAGS Makefile
 	echo "	echo "\''$(subst ','\'',$(instdir_SQ))'\' >> $@
 else
 $(makfile): Makefile.PL ../GIT-CFLAGS
-	$(PERL_PATH) $< PREFIX=\''$(prefix_SQ)'\'
+	$(PERL_PATH) $< PREFIX=\''$(subst ','\'',$(prefix_SQ))'\'
 endif
 
 # this is just added comfort for calling make directly in perl dir
diff --git a/perl/Makefile.PL b/perl/Makefile.PL
index 320253e..e1e465c 100644
--- a/perl/Makefile.PL
+++ b/perl/Makefile.PL
@@ -3,7 +3,7 @@ use ExtUtils::MakeMaker;
 sub MY::postamble {
 	return <<'MAKE_FRAG';
 instlibdir:
-	@echo '$(INSTALLSITELIB)'
+	@echo $(INSTALLSITELIB)
 
 MAKE_FRAG
 }
-- 
1.5.6.2
Previous: Brandon CaseyNext: Brandon Casey
Message 9 of 10 in “perl/Makefile: handle paths with spaces in the NO_PERL_MAKEMAKER section”
  1. perl/Makefile: handle paths with spaces in the NO_PERL_MAKEMAKER sectionBrandon Casey, Aug 5, 2008
  2. Junio C HamanoAug 5, 2008
  3. Brandon CaseyAug 6, 2008
  4. Junio C HamanoAug 6, 2008
  5. Brandon CaseyAug 6, 2008
  6. Junio C HamanoAug 6, 2008
  7. perl/Makefile: handle paths with spaces by adding additional quotingBrandon Casey, Aug 6, 2008
  8. Brandon CaseyAug 6, 2008
  9. Brandon CaseyAug 7, 2008
  10. perl/Makefile: make NO_PERL_MAKEMAKER section more robustBrandon Casey, Aug 6, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.