citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit ca0d8dd50a23736048c042024eb44411b7041014
parent 2c3d3ffe4505db0f2fde3ff1288c679b852e7aac
Author: Kyle Milz <kyle@0x30.net>
Date:   Sat,  9 Jul 2016 22:03:04 -0600

src: be real careful when CITRUN_PATH isn't in PATH

Diffstat:
Msrc/inst_main.cc | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/inst_main.cc b/src/inst_main.cc @@ -48,18 +48,20 @@ clean_path() char *path; if ((path = getenv("PATH")) == NULL) - errx(1, "PATH not set, your build system needs to use " - "the PATH for this tool to be useful."); + errx(1, "PATH must be set"); // Filter CITRUN_PATH out of PATH std::stringstream path_ss(path); std::ostringstream new_path; std::string component; bool first_component = 1; + bool found_citrun_path = 0; while (std::getline(path_ss, component, ':')) { - if (component.compare(STR(CITRUN_PATH)) == 0) + if (component.compare(STR(CITRUN_PATH)) == 0) { + found_citrun_path = 1; continue; + } if (first_component == 0) new_path << ":"; @@ -69,6 +71,9 @@ clean_path() first_component = 0; } + if (!found_citrun_path) + errx(1, "did not find '%s' in PATH", STR(CITRUN_PATH)); + // Set new $PATH setenv("PATH", new_path.str().c_str(), 1); }