Thread (22 messages) flat view 22 messages, 5 authors, 2016-06-15

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

From: Erik Faye-Lund <hidden>
Date: 2016-06-15 22:48:35

On Thu, Apr 8, 2010 at 1:57 PM, Chris Webb [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
 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
Are you sure that all non-Windows platforms have paths.h? It seems
that at least some Open Solaris versions[1] are missing it as well.
Perhaps this should be guarded by a HAVE_PATHS_H define instead?

[1]: http://mail-index.netbsd.org/tech-pkg/2008/11/24/msg002103.html

-- 
Erik "kusma" Faye-Lund
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help