public function runCmd(
        $cmd,
        $exception = '\RuntimeException',
        Closure $callback = null,
        array $noEscapeChars = null
    ) {
        $cmd = escapeshellcmd($cmd);

        if (is_array($noEscapeChars) and !empty($noEscapeChars)) {

            $repl = "\\\\" . implode("|\\\\", $noEscapeChars);
            $cmd = preg_replace_callback(
                "~$repl~",
                function ($found) {
                    return trim($found[0], "\\");
                },
                $cmd
            );
        }

        $this->cmds[] = $cmd;

        $exitStatus = $this->execCmd($cmd, $stdout, $stderr);

        if ($exitStatus > 0) {
            if (!is_null($callback)) {
                $callback($stderr);
            }
            throw new $exception(sprintf('Command exited with %d: %s', $exitStatus, $stderr));
        }

        return $stdout;
    }