+ /*
+ * Glibc violates POSIX by default and skips over non-option arguments and
+ * parses later arguments which look like options as well. But we want to
+ * pass everything except the options unmodified to execvp(). Prefixing
+ * the optstring with "+" fixes this behaver. This is not POSIX
+ * compatible, but the option should be ignored on other systems.
+ */
+ while ((option = getopt(argc, argv, "+Xmhv")) != -1) {
+ switch (option) {
+ case 'X':
+ enable_x11 = 1;
+ break;
+ case 'm':
+ mesg_yes = 1;
+ break;
+ case 'h':
+ usage(argv0);
+ break;
+ case 'v':
+ printf("%s%s\n",
+ PACKAGE_STRING,
+ strlen(GIT_VERSION) ? " (Git " GIT_VERSION ")" : "");
+ exit(EXIT_SUCCESS);
+ break;
+ default:
+ fprintf(stderr, "%s: unknown option '%s'!\n\n",
+ argv0, argv[optind - 1]);
+ usage(argv0);
+ break;
+ }
+ }
+
+ /* No arguments remaining, abort. */
+ if (!argv[optind]) {