Move computation of absolute paths from Makefile to runtime (in preparation for RUNTIME_PREFIX)
[gitweb.git] / exec_cmd.c
index ce6741eb682b59ad638c7bee6ca31e2fcd53f281..114d6389e4703416aa2525bf9f81dd9597d627d4 100644 (file)
@@ -9,11 +9,14 @@ static const char *argv0_path;
 
 const char *system_path(const char *path)
 {
-       if (!is_absolute_path(path) && argv0_path) {
-               struct strbuf d = STRBUF_INIT;
-               strbuf_addf(&d, "%s/%s", argv0_path, path);
-               path = strbuf_detach(&d, NULL);
-       }
+       static const char *prefix = PREFIX;
+       struct strbuf d = STRBUF_INIT;
+
+       if (is_absolute_path(path))
+               return path;
+
+       strbuf_addf(&d, "%s/%s", prefix, path);
+       path = strbuf_detach(&d, NULL);
        return path;
 }
 
@@ -59,9 +62,7 @@ static void add_path(struct strbuf *out, const char *path)
 void setup_path(void)
 {
        const char *old_path = getenv("PATH");
-       struct strbuf new_path;
-
-       strbuf_init(&new_path, 0);
+       struct strbuf new_path = STRBUF_INIT;
 
        add_path(&new_path, argv_exec_path);
        add_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));