Subject: bin/10898: Patch to arp to allow -f -
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jchacon@genuity.net>
List: netbsd-bugs
Date: 08/26/2000 20:28:16
>Number:         10898
>Category:       bin
>Synopsis:       arp allows -f file but not -f - which is useful
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 26 20:29:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     James Chacon
>Release:        1.5_ALPHA2
>Organization:
>Environment:
System: NetBSD quix 1.5_ALPHA NetBSD 1.5_ALPHA (QUIX) #0: Mon Jul 10 20:31:02 EDT 2000 root@quix:/usr/src/sys/arch/i386/compile/QUIX i386

(That's my current running system. I'm working from the current source tree
as of 08/25)
>Description:
arp allows -f filename which is handy if you have multiple things to do
(for instance in a start-up script). However filename must be a real file
which makes creating pipelines a pain (temp files and all that).
A simple fix is to check for -f - and use stdin.

>How-To-Repeat:
Try it:

root:23:19:16_quix:/usr/src/sys>arp -f - < /tmp/out
arp: cannot open -: No such file or directory

>Fix:
root:23:26:22_quix:/usr/src/usr.sbin/arp>cvs diff -r1.1.1.1 arp.c 
Index: arp.c
===================================================================
RCS file: /usr/local/cvs/src/usr.sbin/arp/arp.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 arp.c
*** arp.c       2000/07/10 05:40:50     1.1.1.1
--- arp.c       2000/08/27 03:26:21
***************
*** 175,182 ****
        int i, retval;
        FILE *fp;
  
!       if ((fp = fopen(name, "r")) == NULL)
!               err(1, "cannot open %s", name);
        args[0] = &arg[0][0];
        args[1] = &arg[1][0];
        args[2] = &arg[2][0];
--- 175,186 ----
        int i, retval;
        FILE *fp;
  
!       if (!strcmp ("-", name)) {
!               fp = stdin;
!       } else { 
!               if ((fp = fopen(name, "r")) == NULL)
!                       err(1, "cannot open %s", name);
!       }
        args[0] = &arg[0][0];
        args[1] = &arg[1][0];
        args[2] = &arg[2][0];

>Release-Note:
>Audit-Trail:
>Unformatted: