diff options
Diffstat (limited to 'qarsh.c')
-rw-r--r-- | qarsh.c | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -356,7 +356,7 @@ main(int argc, char *argv[]) { int c; int port = 5008; - char *host; + char *host = NULL; char *remuser = NULL; char *remgroup = NULL; char *args; @@ -373,6 +373,7 @@ main(int argc, char *argv[]) max_timeout = atoi(cp); } +again: while ((c = getopt(argc, argv, "+p:l:g:t:")) != -1) { switch (c) { case 'l': @@ -393,8 +394,24 @@ main(int argc, char *argv[]) usage(argv[0]); exit(1); } } + /* Some programs (rsync) put the hostname before some qarsh options + * We need to pull the hostname out and if there are still args + * keep trying to parse them. (code from OpenSSH) + */ + argc -= optind; + argv += optind; - if ((host = argv[optind++]) == NULL) { + if (argc > 0 && !host && **argv != '-') { + host = *argv; + if (argc > 1) { + optind = 1; + goto again; + } + argc--; + argv++; + } + + if (!host) { usage(argv[0]); exit(1); } @@ -421,8 +438,6 @@ main(int argc, char *argv[]) remuser = strdup(pw->pw_name); } - argc -= optind; - argv += optind; if ((args = copyargs(argv)) == NULL) { usage(argv[0]); exit(1); |