Tobias Stoeckmann <tob...@stoeckmann.org> writes:

> $ sed s/a/b/ /nofile
> sed: 0: /nofile: /nofile
>
> That message doesn't tell me a lot, let's better write
> strerror(errno) if fopen returns NULL:
>
> $ ./sed s/a/b/ /nofile
> sed: 0: /nofile: No such file or directory

That's much nicer, ok jca@

(misc.c:err() already prints the file name)

> Index: main.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/sed/main.c,v
> retrieving revision 1.27
> diff -u -p -u -p -r1.27 main.c
> --- main.c    10 Oct 2015 20:18:30 -0000      1.27
> +++ main.c    25 Oct 2015 20:01:19 -0000
> @@ -389,7 +389,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag
>                       outfname = "stdout";
>               }
>               if ((infile = fopen(fname, "r")) == NULL) {
> -                     err(WARNING, "%s", fname);
> +                     err(WARNING, "%s", strerror(errno));
>                       rval = 1;
>                       continue;
>               }
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to