=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/main.c,v retrieving revision 1.29 retrieving revision 1.30 diff -c -r1.29 -r1.30 *** src/usr.bin/ftp/main.c 1997/04/11 23:14:04 1.29 --- src/usr.bin/ftp/main.c 1997/04/23 20:33:19 1.30 *************** *** 1,4 **** ! /* $OpenBSD: main.c,v 1.29 1997/04/11 23:14:04 millert Exp $ */ /* $NetBSD: main.c,v 1.21 1997/04/05 03:27:39 lukem Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: main.c,v 1.30 1997/04/23 20:33:19 deraadt Exp $ */ /* $NetBSD: main.c,v 1.21 1997/04/05 03:27:39 lukem Exp $ */ /* *************** *** 44,50 **** #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94"; #else ! static char rcsid[] = "$OpenBSD: main.c,v 1.29 1997/04/11 23:14:04 millert Exp $"; #endif #endif /* not lint */ --- 44,50 ---- #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94"; #else ! static char rcsid[] = "$OpenBSD: main.c,v 1.30 1997/04/23 20:33:19 deraadt Exp $"; #endif #endif /* not lint */ *************** *** 75,80 **** --- 75,81 ---- struct passwd *pw = NULL; char *cp, homedir[MAXPATHLEN]; int dumb_terminal = 0; + int outfd = -1; sp = getservbyname("ftp", "tcp"); if (sp == 0) *************** *** 116,123 **** editing = 1; /* editing mode on if from a tty */ #endif } ! if (isatty(fileno(stdout)) && !dumb_terminal) progress = 1; /* progress bar on if going to a tty */ while ((ch = getopt(argc, argv, "adeginpPr:tvV")) != -1) { switch (ch) { --- 117,130 ---- editing = 1; /* editing mode on if from a tty */ #endif } ! ! ttyout = stdout; ! if (isatty(fileno(ttyout)) && !dumb_terminal) progress = 1; /* progress bar on if going to a tty */ + else { + ttyout = stderr; + outfd = fileno(stdout); + } while ((ch = getopt(argc, argv, "adeginpPr:tvV")) != -1) { switch (ch) { *************** *** 210,216 **** if (argc > 0) { if (strchr(argv[0], ':') != NULL) { anonftp = 1; /* Handle "automatic" transfers. */ ! rval = auto_fetch(argc, argv); if (rval >= 0) /* -1 == connected and cd-ed */ exit(rval); } else { --- 217,223 ---- if (argc > 0) { if (strchr(argv[0], ':') != NULL) { anonftp = 1; /* Handle "automatic" transfers. */ ! rval = auto_fetch(argc, argv, outfd); if (rval >= 0) /* -1 == connected and cd-ed */ exit(rval); } else { *************** *** 231,237 **** break; if (!connected) { macnum = 0; ! puts("Retrying..."); sleep(retry_connect); } } while (!connected); --- 238,244 ---- break; if (!connected) { macnum = 0; ! fputs("Retrying...\n", ttyout); sleep(retry_connect); } } while (!connected); *************** *** 314,327 **** && !editing #endif /* !SMALL */ ) ! (void)putchar('\n'); for (;;) { #ifndef SMALL if (!editing) { #endif /* !SMALL */ if (fromatty) { ! fputs(prompt(), stdout); ! (void)fflush(stdout); } if (fgets(line, sizeof(line), stdin) == NULL) quit(0, 0); --- 321,334 ---- && !editing #endif /* !SMALL */ ) ! (void)putc('\n', ttyout); for (;;) { #ifndef SMALL if (!editing) { #endif /* !SMALL */ if (fromatty) { ! fputs(prompt(), ttyout); ! (void)fflush(ttyout); } if (fgets(line, sizeof(line), stdin) == NULL) quit(0, 0); *************** *** 333,339 **** break; line[num] = '\0'; } else if (num == sizeof(line) - 2) { ! puts("sorry, input line too long."); while ((num = getchar()) != '\n' && num != EOF) /* void */; break; --- 340,346 ---- break; line[num] = '\0'; } else if (num == sizeof(line) - 2) { ! fputs("sorry, input line too long.\n", ttyout); while ((num = getchar()) != '\n' && num != EOF) /* void */; break; *************** *** 349,355 **** if (num == 0) break; } else if (num >= sizeof(line)) { ! puts("sorry, input line too long."); break; } memcpy(line, buf, num); --- 356,362 ---- if (num == 0) break; } else if (num >= sizeof(line)) { ! fputs("sorry, input line too long.\n", ttyout); break; } memcpy(line, buf, num); *************** *** 363,369 **** continue; c = getcmd(margv[0]); if (c == (struct cmd *)-1) { ! puts("?Ambiguous command."); continue; } if (c == 0) { --- 370,376 ---- continue; c = getcmd(margv[0]); if (c == (struct cmd *)-1) { ! fputs("?Ambiguous command.\n", ttyout); continue; } if (c == 0) { *************** *** 375,391 **** */ if (el_parse(el, margc, margv) != 0) #endif /* !SMALL */ ! puts("?Invalid command."); continue; } if (c->c_conn && !connected) { ! puts("Not connected."); continue; } confirmrest = 0; (*c->c_handler)(margc, margv); if (bell && c->c_bell) ! (void)putchar('\007'); if (c->c_handler != help) break; } --- 382,398 ---- */ if (el_parse(el, margc, margv) != 0) #endif /* !SMALL */ ! fputs("?Invalid command.\n", ttyout); continue; } if (c->c_conn && !connected) { ! fputs("Not connected.\n", ttyout); continue; } confirmrest = 0; (*c->c_handler)(margc, margv); if (bell && c->c_bell) ! (void)putc('\007', ttyout); if (c->c_handler != help) break; } *************** *** 617,623 **** StringList *buf; buf = sl_init(); ! printf("%sommands may be abbreviated. Commands are:\n\n", proxy ? "Proxy c" : "C"); for (c = cmdtab; c < &cmdtab[NCMDS]; c++) if (c->c_name && (!proxy || c->c_proxy)) --- 624,630 ---- StringList *buf; buf = sl_init(); ! fprintf(ttyout, "%sommands may be abbreviated. Commands are:\n\n", proxy ? "Proxy c" : "C"); for (c = cmdtab; c < &cmdtab[NCMDS]; c++) if (c->c_name && (!proxy || c->c_proxy)) *************** *** 635,645 **** arg = *++argv; c = getcmd(arg); if (c == (struct cmd *)-1) ! printf("?Ambiguous help command %s\n", arg); else if (c == (struct cmd *)0) ! printf("?Invalid help command %s\n", arg); else ! printf("%-*s\t%s\n", HELPINDENT, c->c_name, c->c_help); } } --- 642,652 ---- arg = *++argv; c = getcmd(arg); if (c == (struct cmd *)-1) ! fprintf(ttyout, "?Ambiguous help command %s\n", arg); else if (c == (struct cmd *)0) ! fprintf(ttyout, "?Invalid help command %s\n", arg); else ! fprintf(ttyout, "%-*s\t%s\n", HELPINDENT, c->c_name, c->c_help); } }