mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
Implement -c #none (#1301)
Also adds a test case for round-tripping `-r` with `-c #none`.
This commit is contained in:
@@ -281,6 +281,21 @@ public:
|
||||
};
|
||||
|
||||
static char *execProg(char const *name, char * const *argv) {
|
||||
auto formatArgv = [&argv] {
|
||||
// This is `static` so that the returned `buf.c_str()` will live long enough
|
||||
// for `fatal()` to use it below.
|
||||
static std::string buf;
|
||||
|
||||
buf.clear();
|
||||
for (char * const *arg = argv; *arg != nullptr; ++arg) {
|
||||
buf.push_back('"');
|
||||
buf.append(*arg);
|
||||
buf.append("\", ");
|
||||
}
|
||||
buf.resize(buf.length() - 2);
|
||||
return buf.c_str();
|
||||
};
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
pid_t pid;
|
||||
int err = posix_spawn(&pid, argv[0], nullptr, nullptr, argv, nullptr);
|
||||
@@ -293,10 +308,10 @@ static char *execProg(char const *name, char * const *argv) {
|
||||
fatal("Error waiting for %s: %s", name, strerror(errno));
|
||||
} else if (info.si_code != CLD_EXITED) {
|
||||
assert(info.si_code == CLD_KILLED || info.si_code == CLD_DUMPED);
|
||||
fatal("%s was terminated by signal %s%s", name, strsignal(info.si_status),
|
||||
info.si_code == CLD_DUMPED ? " (core dumped)" : "");
|
||||
fatal("%s was terminated by signal %s%s\n\tThe command was: [%s]", name, strsignal(info.si_status),
|
||||
info.si_code == CLD_DUMPED ? " (core dumped)" : "", formatArgv());
|
||||
} else if (info.si_status != 0) {
|
||||
fatal("%s returned with status %d", name, info.si_status);
|
||||
fatal("%s returned with status %d\n\tThe command was: [%s]", name, info.si_status, formatArgv());
|
||||
}
|
||||
|
||||
#else // defined(_MSC_VER) || defined(__MINGW32__)
|
||||
@@ -362,7 +377,7 @@ static char *execProg(char const *name, char * const *argv) {
|
||||
CloseHandle(child.hThread);
|
||||
|
||||
if (status != 0) {
|
||||
fatal("%s returned with status %ld", name, status);
|
||||
fatal("%s returned with status %ld\n\tThe command was: [%s]", name, status, formatArgv());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user