diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-02-08 17:33:36 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-02-08 17:33:36 +0000 |
commit | cfab5154f9c9d54e393e230ff7331dbff8d8807b (patch) | |
tree | c8d8ab5eed56ccc6fb8c2c558a330e9c9d5e8a12 /usr.bin/cu/cu.c | |
parent | 7f65aff6163bb5dc6b8c737abe315531db182c55 (diff) |
Separate the two usages for cu so you can either give it -l and -s (like
cu) or you can give it a host to look up in /etc/remote (like
tip). Mixing the two was unclear and caused mixups with -l and the HOST
environment variable.
So usage is now:
usage: cu [-l line] [-s speed | -speed]
cu [host]
And HOST and REMOTE are ignored for the first form.
ok deraadt claudio
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); + } } } |