

You can call rm safer manner, but you’ll need to fork and use one of the execl functions directly. That way you don’t have to worry about escaping the path. The old implement would potentially delete unrelated data if the path contained whitespace, and could even execute arbitrary commands, since it essentially runs bash -c "rm -rf $path"

To add to the last comment, I’d also suggest not mixing logging and business code. That is to say that you should put the
systemcall on its own line, so that it is clear that it’s not just a logging call:if (!strcmp(platform, "windows") && !isSpecificPlatform) { debugLog("Falling back to rm -rf", 2); int result = system(strfmt("rm -rf %s", path)); debugLog(strfmt("rm -rf exited with code %d", result), 3); }It may just be a me problem, but I have a tendency to skim over the logging lines unless I’m intentionally reading code carefully, in which case the system call may get overlooked