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

[PATCH v2] Replace hard-coded path with one from <paths.h>

From
Chris Webb <chris@arachsys.com>
Date
Apr 8, 2010, 11:57 UTC
Message-ID
<20100408115706.GE2077@arachsys.com>
In-Reply-To
<m2x40aa078e1004080426u98fbe6b2zfa9a2726172f725@mail.gmail.com>

In exec_cmd.c, git hard-codes a default path of /usr/local/bin:/usr/bin:/bin. Get an appropriate value for the system from <paths.h> if possible instead. Do not attempt to #include <paths.h> under Windows.

Signed-off-by: Chris Webb <chris@arachsys.com>
---
 exec_cmd.c        |    2 +-
 git-compat-util.h |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/exec_cmd.c b/exec_cmd.c
index b2c07c7..bf22570 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -107,7 +107,7 @@ void setup_path(void)
 	if (old_path)
 		strbuf_addstr(&new_path, old_path);
 	else
-		strbuf_addstr(&new_path, "/usr/local/bin:/usr/bin:/bin");
+		strbuf_addstr(&new_path, _PATH_DEFPATH);
 
 	setenv("PATH", new_path.buf, 1);
 
diff --git a/git-compat-util.h b/git-compat-util.h
index 7e62b55..9443b9b 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -70,6 +70,8 @@
 #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */
 #include <winsock2.h>
 #include <windows.h>
+#else
+#include <paths.h>
 #endif
 
 #include <unistd.h>
@@ -164,6 +166,10 @@ extern char *gitbasename(char *);
 #define PATH_SEP ':'
 #endif
 
+#ifndef _PATH_DEFPATH
+#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin"
+#endif
+
 #ifndef STRIP_EXTENSION
 #define STRIP_EXTENSION ""
 #endif
-- 
1.7.0.3
Previous: Erik Faye-LundNext: Erik Faye-Lund
Message 9 of 24 in “Replace hard-coded path with one configurable at make time”
  1. Replace hard-coded path with one configurable at make timeChris Webb, Apr 4, 2010
  2. Junio C HamanoApr 4, 2010
  3. Chris WebbApr 4, 2010
  4. Chris WebbApr 6, 2010
  5. Replace hard-coded path with one from <paths.h>Chris Webb, Apr 6, 2010
  6. Erik Faye-LundApr 7, 2010
  7. Chris WebbApr 8, 2010
  8. Erik Faye-LundApr 8, 2010
  9. Replace hard-coded path with one from <paths.h>Chris Webb, Apr 8, 2010
  10. Erik Faye-LundApr 8, 2010
  11. Chris WebbApr 9, 2010
  12. Chris WebbApr 13, 2010
  13. Replace hard-coded path with one from <paths.h>Chris Webb, Apr 13, 2010
  14. Junio C HamanoApr 13, 2010
  15. Chris WebbApr 14, 2010
  16. Jakub NarebskiApr 15, 2010
  17. Junio C HamanoApr 15, 2010
  18. Jakub NarebskiApr 15, 2010
  19. Chris WebbApr 15, 2010
  20. Jakub NarebskiApr 15, 2010
  21. Chris WebbApr 15, 2010
  22. Replace hard-coded path with one from <paths.h>Chris Webb, Apr 15, 2010
  23. TaitApr 9, 2010
  24. git-instaweb: pass through invoking user's path to gitweb CGI scriptChris Webb, Apr 6, 2010

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.