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 | |
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')
-rw-r--r-- | usr.bin/cu/cu.1 | 5 | ||||
-rw-r--r-- | usr.bin/cu/cu.c | 35 |
2 files changed, 23 insertions, 17 deletions
diff --git a/usr.bin/cu/cu.1 b/usr.bin/cu/cu.1 index 035e3793cf7..057490effea 100644 --- a/usr.bin/cu/cu.1 +++ b/usr.bin/cu/cu.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cu.1,v 1.11 2014/03/31 09:09:19 nicm Exp $ +.\" $OpenBSD: cu.1,v 1.12 2015/02/08 17:33:35 nicm Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)tip.1 8.4 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: March 31 2014 $ +.Dd $Mdocdate: February 8 2015 $ .Dt CU 1 .Os .Sh NAME @@ -39,6 +39,7 @@ .Nm .Op Fl l Ar line .Op Fl s Ar speed \*(Ba Fl Ar speed +.Nm .Op Ar host .Sh DESCRIPTION .Nm 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); + } } } |