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

[PATCH] Makefile: use shell for-loop rather than Make's foreach loop during install

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Jan 20, 2009, 01:41 UTC
Message-ID
<IabvnnitcJMS2DjNwgzy1-XPpTZ5XUD1yCbZhuv3bgnTXi4eLY33JtDkQKLr5q3lh1kyMtC3WfU@cipher.nrlssc.navy.mil>

The install target uses a foreach loop to generate a single long shell command line to handle installation of the built-in git commands. The maximum length of the argument list varies by platform, and this use of foreach quickly grows the length of the argument list. Current git can exceed the default maximum argument list length on IRIX 6.5 of 20480 depending on the installation path.

Rather than using make's foreach loop to pre-generate the shell command line, use a shell for-loop and allow the shell to iterate through each of the built-in commands.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 Makefile |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 2b873fa..fa6c51c 100644
--- a/Makefile
+++ b/Makefile
@@ -1441,10 +1441,12 @@ endif
 	{ $(RM) "$$execdir/git-add$X" && \
 		ln git-add$X "$$execdir/git-add$X" 2>/dev/null || \
 		cp git-add$X "$$execdir/git-add$X"; } && \
-	{ $(foreach p,$(filter-out git-add$X,$(BUILT_INS)), $(RM) "$$execdir/$p" && \
-		ln "$$execdir/git-add$X" "$$execdir/$p" 2>/dev/null || \
-		ln -s "git-add$X" "$$execdir/$p" 2>/dev/null || \
-		cp "$$execdir/git-add$X" "$$execdir/$p" || exit;) } && \
+	{ for p in $(filter-out git-add$X,$(BUILT_INS)); do \
+		$(RM) "$$execdir/$$p" && \
+		ln "$$execdir/git-add$X" "$$execdir/$$p" 2>/dev/null || \
+		ln -s "git-add$X" "$$execdir/$$p" 2>/dev/null || \
+		cp "$$execdir/git-add$X" "$$execdir/$$p" || exit; \
+	  done } && \
 	./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
 
 install-doc:
-- 
1.6.1.239.gcf3bf
Message 1 of 1 in “Makefile: use shell for-loop rather than Make's foreach loop during install”
  1. Makefile: use shell for-loop rather than Make's foreach loop during installBrandon Casey, Jan 20, 2009

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.