$ 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

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;
                }

Reply via email to