diff options
author | des <des@FreeBSD.org> | 1998-09-17 00:15:15 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 1998-09-17 00:15:15 +0000 |
commit | 8b07d06aca0b6f811c9092a6f5f12c1099dcbf59 (patch) | |
tree | de2e9f9d7228b617fa72f09ff8643039851eb49b /usr.bin/fetch | |
parent | e0db131ba028922d0f48f643f31bda5630ef9d89 (diff) | |
download | FreeBSD-src-8b07d06aca0b6f811c9092a6f5f12c1099dcbf59.zip FreeBSD-src-8b07d06aca0b6f811c9092a6f5f12c1099dcbf59.tar.gz |
DTRT for file: URLs when output file is "-".
PR: bin/7203
Diffstat (limited to 'usr.bin/fetch')
-rw-r--r-- | usr.bin/fetch/file.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.bin/fetch/file.c b/usr.bin/fetch/file.c index 2505353..cad33e7 100644 --- a/usr.bin/fetch/file.c +++ b/usr.bin/fetch/file.c @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: file.c,v 1.2 1997/11/08 22:15:55 obrien Exp $ + * $Id: file.c,v 1.3 1997/11/12 04:39:33 obrien Exp $ */ #include <sys/types.h> @@ -118,6 +118,22 @@ file_retrieve(struct fetch_state *fs) return EX_OSERR; } fs->fs_status = "done"; + } else if (strcmp(fs->fs_outputfile, "-") == 0) { + FILE *f; + int ch; + + if ((f = fopen(fs->fs_proto, "r")) == NULL) { + warn("fopen"); + return EX_OSERR; + } + while ((ch = fgetc(f)) != EOF) + fputc(ch, stdout); + if (ferror(f)) { + warn("fgetc"); + fclose(f); + return EX_OSERR; + } + fclose(f); } else { pid_t pid; int status; |