Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdlib: Version of readback that returns error code when the system command fails #59

Open
rsaarelm opened this issue Mar 15, 2024 · 1 comment

Comments

@rsaarelm
Copy link

Possible implementation:

(int | string) readbackErr(string command) {
    import std.file : readText, remove;
    import std.string : toStringz;

    auto tmp = tmpnam(null).cToString;
    // XXX: Pipe stderr to devnull to make program errors not propagate to our stderr.
    int iret = neat_runtime_system_iret(command ~ " > " ~ tmp ~ " 2> /dev/null");
    auto ret = readText(tmp);
    remove(tmp);
    if (iret)
        return iret;
    return ret;
}

@FeepingCreature
Copy link
Contributor

Should probably be implemented as a whole Process class with stdin/stdout/stderr redirection options and a .status flag, so we don't need fifty functions for fifty combinations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants