45 lines
947 B
C++
45 lines
947 B
C++
|
/*
|
||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||
|
*
|
||
|
* Copyright 2019 Danny Robson <danny@nerdcruft.net>
|
||
|
*/
|
||
|
|
||
|
#include <iostream>
|
||
|
#include <cstddef>
|
||
|
#include <sstream>
|
||
|
|
||
|
#include <unistd.h>
|
||
|
|
||
|
#include <cruft/util/debug.hpp>
|
||
|
#include <cruft/util/posix/except.hpp>
|
||
|
|
||
|
|
||
|
enum {
|
||
|
ARG_SELF,
|
||
|
ARG_CHILD,
|
||
|
|
||
|
NUM_ARGS
|
||
|
};
|
||
|
|
||
|
|
||
|
static void print_usage (std::ostream &os, int argc, char **argv)
|
||
|
{
|
||
|
(void)argc;
|
||
|
os << "Usage: " << argv[ARG_SELF] << " <command> [args] ...\n";
|
||
|
}
|
||
|
|
||
|
|
||
|
int main (int argc, char **argv)
|
||
|
{
|
||
|
if (argc < NUM_ARGS) {
|
||
|
print_usage (std::cerr, argc, argv);
|
||
|
return EXIT_FAILURE;
|
||
|
}
|
||
|
|
||
|
std::ostringstream os;
|
||
|
os << argv[ARG_SELF] << '-' << argv[ARG_CHILD];
|
||
|
cruft::posix::error::try_call (execv, os.str ().c_str (), argv + 1);
|
||
|
unreachable ();
|
||
|
}
|