SCP: Avoid 'not found' error in tool path locater on Windows

This commit is contained in:
Mark Pizzolato 2021-09-20 07:37:14 -07:00
parent 0bc77c4d90
commit 2834bfb1f9

4
scp.c
View file

@ -6405,13 +6405,15 @@ FILE *f;
#if defined(_WIN32) #if defined(_WIN32)
#define FIND_CMD "where" #define FIND_CMD "where"
#define FIND_CMD2 "2>NUL"
#define popen _popen #define popen _popen
#define pclose _pclose #define pclose _pclose
#else #else
#define FIND_CMD "which" #define FIND_CMD "which"
#define FIND_CMD2 ""
#endif #endif
memset (toolpath, 0, sizeof(toolpath)); memset (toolpath, 0, sizeof(toolpath));
snprintf (findcmd, sizeof (findcmd), "%s %s", FIND_CMD, tool); snprintf (findcmd, sizeof (findcmd), "%s %s %s", FIND_CMD, tool, FIND_CMD2);
if ((f = popen (findcmd, "r"))) { if ((f = popen (findcmd, "r"))) {
do { do {
if (NULL == fgets (toolpath, sizeof(toolpath)-1, f)) if (NULL == fgets (toolpath, sizeof(toolpath)-1, f))