From owner-freebsd-bugs Tue Jul 7 15:40:22 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA13663 for freebsd-bugs-outgoing; Tue, 7 Jul 1998 15:40:22 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA13649 for ; Tue, 7 Jul 1998 15:40:18 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id PAA13416; Tue, 7 Jul 1998 15:40:02 -0700 (PDT) Received: from vinson.ca.sandia.gov (vinson.ca.sandia.gov [146.246.243.200]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA13450 for ; Tue, 7 Jul 1998 15:38:07 -0700 (PDT) (envelope-from bmah@vinson.ca.sandia.gov) Received: (from bmah@localhost) by vinson.ca.sandia.gov (8.8.8/8.8.8) id PAA09782; Tue, 7 Jul 1998 15:37:39 -0700 (PDT) (envelope-from bmah) Message-Id: <199807072237.PAA09782@vinson.ca.sandia.gov> Date: Tue, 7 Jul 1998 15:37:39 -0700 (PDT) From: bmah@ca.sandia.gov Reply-To: bmah@ca.sandia.gov To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/7203: [PATCH] fetch -o - file:/path/name doesn't go to stdout Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 7203 >Category: bin >Synopsis: [PATCH] fetch -o - file:/path/name doesn't go to stdout >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jul 7 15:40:01 PDT 1998 >Last-Modified: >Originator: Bruce A. Mah >Organization: Sandia National Laboratories >Release: FreeBSD 2.2.6-RELEASE i386 >Environment: Observed on 2.2.6-RELEASE, but it appears that all versions of fetch(1) in the CVS tree have this problem. >Description: "fetch -o - url://file/name" generally retrieves the URL to stdout. However, in the case of "file:/" URLs, fetch(1) creates a file called "-" in the current directory, containing the file contents. >How-To-Repeat: fetch -o - /etc/hosts cat ./- >Fix: *** fetch.h.orig Tue Jul 7 15:06:41 1998 --- fetch.h Tue Jul 7 15:06:55 1998 *************** *** 36,41 **** --- 36,42 ---- #define BUFFER_SIZE 1024 #define FETCH_VERSION "fetch/1.0" #define PATH_CP "/bin/cp" + #define PATH_CAT "/bin/cat" struct fetch_state { const char *fs_status; *** file.c.orig Tue Jul 7 15:07:56 1998 --- file.c Tue Jul 7 15:13:18 1998 *************** *** 98,112 **** file_retrieve(struct fetch_state *fs) { struct stat sb; ! /* XXX - this seems bogus to me! */ ! if (access(fs->fs_outputfile, F_OK) == 0) { ! errno = EEXIST; ! warn("%s", fs->fs_outputfile); ! return EX_USAGE; } ! if (fs->fs_linkfile) { fs->fs_status = "checking path"; if (stat(fs->fs_proto, &sb) == -1) { warn("non-unexistent"); --- 98,116 ---- file_retrieve(struct fetch_state *fs) { struct stat sb; + int to_stdout; ! to_stdout = (strcmp(fs->fs_outputfile, "-") == 0); ! if (!to_stdout) { ! /* XXX - this seems bogus to me! */ ! if (access(fs->fs_outputfile, F_OK) == 0) { ! errno = EEXIST; ! warn("%s", fs->fs_outputfile); ! return EX_USAGE; ! } } ! if ((fs->fs_linkfile) && (!to_stdout)) { fs->fs_status = "checking path"; if (stat(fs->fs_proto, &sb) == -1) { warn("non-unexistent"); *************** *** 128,136 **** warn("fork"); return EX_TEMPFAIL; } else if (pid == 0) { ! execl(PATH_CP, "cp", "-p", fs->fs_proto, ! fs->fs_outputfile, (char *)0); ! warn("execl: " PATH_CP); fflush(stderr); _exit(EX_OSERR); } else { --- 132,146 ---- warn("fork"); return EX_TEMPFAIL; } else if (pid == 0) { ! if (to_stdout) { ! execl(PATH_CAT, "cat", fs->fs_proto, ! (char *)0); ! warn("execl: " PATH_CAT); ! } else { ! execl(PATH_CP, "cp", "-p", fs->fs_proto, ! fs->fs_outputfile, (char *)0); ! warn("execl: " PATH_CP); ! } fflush(stderr); _exit(EX_OSERR); } else { >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message