diff options
Diffstat (limited to 'usr.bin/cu/cu.c')
-rw-r--r-- | usr.bin/cu/cu.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/usr.bin/cu/cu.c b/usr.bin/cu/cu.c index 99a9b057430..52e2f94f357 100644 --- a/usr.bin/cu/cu.c +++ b/usr.bin/cu/cu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cu.c,v 1.20 2015/01/16 06:40:06 deraadt Exp $ */ +/* $OpenBSD: cu.c,v 1.21 2015/02/08 17:33:35 nicm Exp $ */ /* * Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org> @@ -65,8 +65,9 @@ void try_remote(const char *, const char *, const char *); __dead void usage(void) { - fprintf(stderr, "usage: %s [-l line] [-s speed | -speed] [host]\n", + fprintf(stderr, "usage: %s [-l line] [-s speed | -speed]\n", __progname); + fprintf(stderr, " %s [host]\n", __progname); exit(1); } @@ -113,20 +114,24 @@ main(int argc, char **argv) if (argc != 0 && argc != 1) usage(); - if (argc == 1) - host = argv[0]; - else - host = getenv("HOST"); - if (host != NULL && *host != '\0') { - if (*host == '/') { - if (line_path == NULL) + if (line_path != NULL || line_speed != -1) { + if (argc != 0) + usage(); + } else { + if (argc == 1) + host = argv[0]; + else + host = getenv("HOST"); + if (host != NULL && *host != '\0') { + if (*host == '/') line_path = host; - } else { - s = getenv("REMOTE"); - if (s != NULL && *s == '/') - try_remote(host, s, NULL); - else - try_remote(host, NULL, s); + else { + s = getenv("REMOTE"); + if (s != NULL && *s == '/') + try_remote(host, s, NULL); + else + try_remote(host, NULL, s); + } } } |