summaryrefslogtreecommitdiff
path: root/usr.bin/ftp
diff options
context:
space:
mode:
authorAlexander Hall <halex@cvs.openbsd.org>2010-06-29 23:12:34 +0000
committerAlexander Hall <halex@cvs.openbsd.org>2010-06-29 23:12:34 +0000
commit59b73cb93a92df2724907f10a108787ecda54fff (patch)
tree5ba00dfd068988c6a9fe293cda1aa9152c403bd6 /usr.bin/ftp
parentd89d127e66ee4af18d3882acb5640e109ef4ce1b (diff)
fix output handling:
- if a remote file by the name '-' is retrieved, that does not imply it should go to standard output... - make -o '' reset any previous -o action - properly handle multiple -o 's ok phessler@
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r--usr.bin/ftp/extern.h3
-rw-r--r--usr.bin/ftp/fetch.c8
-rw-r--r--usr.bin/ftp/main.c13
3 files changed, 16 insertions, 8 deletions
diff --git a/usr.bin/ftp/extern.h b/usr.bin/ftp/extern.h
index 855b9f779fe..f8d930c535b 100644
--- a/usr.bin/ftp/extern.h
+++ b/usr.bin/ftp/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.40 2010/04/30 19:29:01 jsg Exp $ */
+/* $OpenBSD: extern.h,v 1.41 2010/06/29 23:12:33 halex Exp $ */
/* $NetBSD: extern.h,v 1.17 1997/08/18 10:20:19 lukem Exp $ */
/*
@@ -137,6 +137,7 @@ extern int proxy;
extern char reply_string[];
extern off_t restart_point;
extern int keep_alive_timeout;
+extern int pipeout;
#ifndef SMALL
extern int NCMDS;
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index 391706924bc..bd6d71a700a 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fetch.c,v 1.99 2010/06/03 07:50:02 halex Exp $ */
+/* $OpenBSD: fetch.c,v 1.100 2010/06/29 23:12:33 halex Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
@@ -259,7 +259,7 @@ noslash:
}
#ifndef SMALL
- if (resume && (strcmp(savefile, "-") == 0)) {
+ if (resume && pipeout) {
warnx("can't append to stdout");
goto cleanup_url_get;
}
@@ -337,7 +337,7 @@ noslash:
filesize = st.st_size;
/* Open the output file. */
- if (strcmp(savefile, "-") != 0) {
+ if (!pipeout) {
#ifndef SMALL
if (resume)
out = open(savefile, O_CREAT | O_WRONLY |
@@ -758,7 +758,7 @@ again:
}
/* Open the output file. */
- if (strcmp(savefile, "-") != 0) {
+ if (!pipeout) {
#ifndef SMALL
if (resume)
out = open(savefile, O_CREAT | O_WRONLY | O_APPEND,
diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c
index 49ad5ae4612..e4ba176635a 100644
--- a/usr.bin/ftp/main.c
+++ b/usr.bin/ftp/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.80 2009/08/09 18:36:11 sobrado Exp $ */
+/* $OpenBSD: main.c,v 1.81 2010/06/29 23:12:33 halex Exp $ */
/* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */
/*
@@ -79,6 +79,7 @@
#include "cmds.h"
int family = PF_UNSPEC;
+int pipeout;
int
main(volatile int argc, char *argv[])
@@ -246,8 +247,14 @@ main(volatile int argc, char *argv[])
case 'o':
outfile = optarg;
- if (strcmp(outfile, "-") == 0)
- ttyout = stderr;
+ if (*outfile == '\0') {
+ pipeout = 0;
+ outfile = NULL;
+ ttyout = stdout;
+ } else {
+ pipeout = strcmp(outfile, "-") == 0;
+ ttyout = pipeout ? stderr : stdout;
+ }
break;
case 'p':