X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tmp-objdir.c;h=b2d9280f104aec7095dd2b37ff1f7165355b5388;hb=3b8a1e1e455fd979a37107581099869113bca442;hp=64435f23a483dfc40e91437f0689bdfb9ac4b8f8;hpb=46e398b69c0f68ade36b2a3e224a9ce3908eb26e;p=platform%2Fupstream%2Fgit.git diff --git a/tmp-objdir.c b/tmp-objdir.c index 64435f2..b2d9280 100644 --- a/tmp-objdir.c +++ b/tmp-objdir.c @@ -5,6 +5,7 @@ #include "string-list.h" #include "strbuf.h" #include "argv-array.h" +#include "quote.h" struct tmp_objdir { struct strbuf path; @@ -79,12 +80,27 @@ static void remove_tmp_objdir_on_signal(int signo) */ static void env_append(struct argv_array *env, const char *key, const char *val) { - const char *old = getenv(key); + struct strbuf quoted = STRBUF_INIT; + const char *old; + /* + * Avoid quoting if it's not necessary, for maximum compatibility + * with older parsers which don't understand the quoting. + */ + if (*val == '"' || strchr(val, PATH_SEP)) { + strbuf_addch("ed, '"'); + quote_c_style(val, "ed, NULL, 1); + strbuf_addch("ed, '"'); + val = quoted.buf; + } + + old = getenv(key); if (!old) argv_array_pushf(env, "%s=%s", key, val); else argv_array_pushf(env, "%s=%s%c%s", key, old, PATH_SEP, val); + + strbuf_release("ed); } static void env_replace(struct argv_array *env, const char *key, const char *val)