diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2020-07-22 11:52:13 +1000 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-07-25 11:05:14 +0300 |
commit | 31b38c31379ba9cbb2f4cece44b8cd2a37d0db95 (patch) | |
tree | cff00b9d5e99d1b9ca9842437b0cbf7adf53c486 /tools | |
parent | ba52e34dcec20c19774e279386b8f991dc1dd616 (diff) | |
download | xorg-lib-libxkbcommon-31b38c31379ba9cbb2f4cece44b8cd2a37d0db95.tar.gz |
tools: don't mangle the path for tools, just exec directly
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools-common.c | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/tools/tools-common.c b/tools/tools-common.c index f7539fe..a78bc9a 100644 --- a/tools/tools-common.c +++ b/tools/tools-common.c @@ -206,27 +206,11 @@ tools_enable_stdin_echo(void) #endif -static inline bool -tools_setup_path(void) -{ - const char *path = getenv("PATH"); - const char *extra_path = LIBXKBCOMMON_TOOL_PATH; - char new_path[PATH_MAX]; - - if (snprintf_safe(new_path, sizeof(new_path), "%s:%s", - extra_path, path ? path : "")) { - setenv("PATH", new_path, 1); - return true; - } else { - return false; - } -} - int tools_exec_command(const char *prefix, int real_argc, char **real_argv) { char *argv[64] = {NULL}; - char executable[128]; + char executable[PATH_MAX]; const char *command; if (((size_t)real_argc >= ARRAY_SIZE(argv))) { @@ -235,23 +219,24 @@ tools_exec_command(const char *prefix, int real_argc, char **real_argv) } command = real_argv[0]; +#ifdef _MSC_VER +#define PATH_SEP '\\' +#else +#define PATH_SEP '/' +#endif if (!snprintf_safe(executable, sizeof(executable), - "%s-%s", prefix, command)) { + "%s%c%s-%s", LIBXKBCOMMON_TOOL_PATH, PATH_SEP, + prefix, command)) { fprintf(stderr, "Failed to assemble command\n"); return EXIT_FAILURE; } - if (!tools_setup_path()) { - fprintf(stderr, "Failed to set PATH\n"); - return EXIT_FAILURE; - } - argv[0] = executable; for (int i = 1; i < real_argc; i++) argv[i] = real_argv[i]; - execvp(executable, argv); + execv(executable, argv); if (errno == ENOENT) { fprintf(stderr, "Command '%s' is not available\n", command); return EXIT_INVALID_USAGE; |