=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/main.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- src/usr.bin/ftp/main.c 1997/12/17 16:03:05 1.37 +++ src/usr.bin/ftp/main.c 1998/02/17 23:22:56 1.38 @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.37 1997/12/17 16:03:05 millert Exp $ */ +/* $OpenBSD: main.c,v 1.38 1998/02/17 23:22:56 millert Exp $ */ /* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */ /* @@ -44,7 +44,7 @@ #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.37 1997/12/17 16:03:05 millert Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.38 1998/02/17 23:22:56 millert Exp $"; #endif #endif /* not lint */ @@ -77,8 +77,8 @@ long port; struct passwd *pw = NULL; char *cp, *ep, homedir[MAXPATHLEN]; + char *outfile = NULL; int dumb_terminal = 0; - int outfd = -1; sp = getservbyname("ftp", "tcp"); if (sp == 0) @@ -170,12 +170,7 @@ if (isatty(fileno(ttyout)) && !dumb_terminal && foregroundproc()) progress = 1; /* progress bar on if tty is usable */ - if (!isatty(fileno(ttyout))) { - outfd = fileno(stdout); - ttyout = stderr; - } - - while ((ch = getopt(argc, argv, "AadeginpPr:tvV")) != -1) { + while ((ch = getopt(argc, argv, "Aadegino:pPr:tvV")) != -1) { switch (ch) { case 'A': activefallback = 0; @@ -209,6 +204,12 @@ autologin = 0; break; + case 'o': + outfile = optarg; + if (strcmp(outfile, "-") == 0) + ttyout = stderr; + break; + case 'p': passivemode = 1; activefallback = 0; @@ -277,7 +278,7 @@ if (argc > 0) { if (strchr(argv[0], ':') != NULL) { anonftp = 1; /* Handle "automatic" transfers. */ - rval = auto_fetch(argc, argv, outfd); + rval = auto_fetch(argc, argv, outfile); if (rval >= 0) /* -1 == connected and cd-ed */ exit(rval); } else {