diff options
author | Martynas Venckus <martynas@cvs.openbsd.org> | 2008-06-16 19:56:05 +0000 |
---|---|---|
committer | Martynas Venckus <martynas@cvs.openbsd.org> | 2008-06-16 19:56:05 +0000 |
commit | a2a6560af51ef84eb84ec9dc5fc684893fbbd556 (patch) | |
tree | 4231cd3f8ee28318ee0ef1b3fdf8ab4e0d52f15b /usr.bin/ftp | |
parent | a72c40ca9787b2cb58d787b68493eeb21afca8d5 (diff) |
- add 'q', which does the same as eof
- add '?', which will help
- make use of mflag, instead of special-case interactive
- change mflag++ to mflag = 1, because theoretically it can go out
of range
"i like it" millert@. man page help and ok jmc@
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r-- | usr.bin/ftp/cmds.c | 14 | ||||
-rw-r--r-- | usr.bin/ftp/ftp.1 | 12 | ||||
-rw-r--r-- | usr.bin/ftp/util.c | 47 |
3 files changed, 43 insertions, 30 deletions
diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c index 53cf2bb36c3..111664734c3 100644 --- a/usr.bin/ftp/cmds.c +++ b/usr.bin/ftp/cmds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmds.c,v 1.60 2008/06/16 12:03:51 martynas Exp $ */ +/* $OpenBSD: cmds.c,v 1.61 2008/06/16 19:56:04 martynas Exp $ */ /* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */ /* @@ -60,7 +60,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: cmds.c,v 1.60 2008/06/16 12:03:51 martynas Exp $"; +static const char rcsid[] = "$OpenBSD: cmds.c,v 1.61 2008/06/16 19:56:04 martynas Exp $"; #endif /* not lint and not SMALL */ /* @@ -364,7 +364,7 @@ mput(int argc, char *argv[]) cp, tp, cp != tp || !interactive); if (!mflag && fromatty) { if (confirm("Continue with", "mput", 1)) - mflag++; + mflag = 1; } } } @@ -385,7 +385,7 @@ mput(int argc, char *argv[]) argv[i], tp, tp != argv[i] || !interactive); if (!mflag && fromatty) { if (confirm("Continue with", "mput", 1)) - mflag++; + mflag = 1; } } continue; @@ -406,7 +406,7 @@ mput(int argc, char *argv[]) *cpp, tp, *cpp != tp || !interactive); if (!mflag && fromatty) { if (confirm("Continue with", "mput", 1)) - mflag++; + mflag = 1; } } } @@ -583,7 +583,7 @@ mget(int argc, char *argv[]) tp != cp || !interactive, 1); if (!mflag && fromatty) { if (confirm("Continue with", "mget", 1)) - mflag++; + mflag = 1; } } } @@ -1025,7 +1025,7 @@ mdelete(int argc, char *argv[]) (void)command("DELE %s", cp); if (!mflag && fromatty) { if (confirm("Continue with", "mdelete", 0)) - mflag++; + mflag = 1; } } } diff --git a/usr.bin/ftp/ftp.1 b/usr.bin/ftp/ftp.1 index 248413a5885..9340f04228a 100644 --- a/usr.bin/ftp/ftp.1 +++ b/usr.bin/ftp/ftp.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ftp.1,v 1.68 2008/03/10 22:56:43 espie Exp $ +.\" $OpenBSD: ftp.1,v 1.69 2008/06/16 19:56:04 martynas Exp $ .\" $NetBSD: ftp.1,v 1.22 1997/08/18 10:20:22 lukem Exp $ .\" .\" Copyright (c) 1985, 1989, 1990, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd $Mdocdate: March 10 2008 $ +.Dd $Mdocdate: June 16 2008 $ .Dt FTP 1 .Os .Sh NAME @@ -860,6 +860,8 @@ will delete all files. .Pp When prompting is on, the following commands are available at a prompt: .Bl -tag -width 2n -offset indent +.It Ic ?\& +Print help message. .It Ic a Answer .Dq yes @@ -875,6 +877,12 @@ to the current file and turn off prompt mode (as if .Dq prompt off had been given). +.It Ic q +Answer +.Dq no +to the current file and automatically answer +.Dq no +to any remaining files for the current command. .It Ic y Transfer the file. .El diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c index 9b87f504dfd..e7cf9b6a40d 100644 --- a/usr.bin/ftp/util.c +++ b/usr.bin/ftp/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.50 2008/06/16 12:03:51 martynas Exp $ */ +/* $OpenBSD: util.c,v 1.51 2008/06/16 19:56:04 martynas Exp $ */ /* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */ /*- @@ -71,7 +71,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: util.c,v 1.50 2008/06/16 12:03:51 martynas Exp $"; +static const char rcsid[] = "$OpenBSD: util.c,v 1.51 2008/06/16 19:56:04 martynas Exp $"; #endif /* not lint and not SMALL */ /* @@ -463,40 +463,45 @@ confirm(const char *cmd, const char *file, int force) { char str[BUFSIZ]; - - if (force) - goto top; - - if (confirmrest == -1) - return (0); - - if (confirmrest || !interactive) + if (!force && (confirmrest || !interactive)) return (1); top: fprintf(ttyout, "%s %s? ", cmd, file); (void)fflush(ttyout); - if (fgets(str, sizeof(str), stdin) == NULL) { - if (!force) - confirmrest = -1; - clearerr(stdin); - return (0); - } + if (fgets(str, sizeof(str), stdin) == NULL) + goto quit; switch (tolower(*str)) { + case '?': + fprintf(ttyout, + "? help\n" + "a answer yes to all\n" + "n answer no\n" + "p turn off prompt mode\n" + "q answer no to all\n" + "y answer yes\n"); + goto top; + case 'a': + confirmrest = 1; + fprintf(ttyout, "Prompting off for duration of %s.\n", + cmd); + break; case 'n': return (0); case 'p': interactive = 0; fputs("Interactive mode: off.\n", ttyout); break; - case 'a': - confirmrest = 1; - fprintf(ttyout, "Prompting off for duration of %s.\n", cmd); - break; + case 'q': +quit: + mflag = 0; + clearerr(stdin); + return (0); case 'y': return(1); break; default: - fprintf(ttyout, "n, y, p, a, are the only acceptable commands!\n"); + fprintf(ttyout, "?, a, n, p, q, y " + "are the only acceptable commands!\n"); goto top; break; } |