Permalink
Browse files

wrapper: explictly warn about unknown options

Reported as item #1 here:

    #13
  • Loading branch information...
1 parent 224ca5d commit 7c2e3d510402459b69982b8ae1546a7c0d1b1b18 @ChrisJohnsen committed Jul 29, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 reattach-to-user-namespace.c
@@ -51,18 +51,23 @@ static const char usage_msg[] = "\n"
" rewrite the program's argv[0] so that it starts with a '-'.\n";
int main(int argc, char *argv[]) {
- unsigned int login = 0;
+ unsigned int login = 0, usage = 0;
if (argc > 1) {
if (!strcmp(argv[1], "-l")) {
login = 1;
argv[1] = argv[0];
argv++;
argc--;
+ } else if (*argv[1] == '-') {
+ warn("unkown option: %s", argv[1]);
+ usage = 2;
}
}
if (argc < 2)
- die(1, "usage: %s [-l] <program> [args...]\n%s", argv[0], usage_msg);
+ usage = 1;
+ if (usage)
+ die(usage, "usage: %s [-l] <program> [args...]\n%s", argv[0], usage_msg);
unsigned int os = 0;

0 comments on commit 7c2e3d5

Please sign in to comment.