Hi,
I noticed that when doing `sed -i` on a file you don't have
permission to read, the error message printed isn't very helpful:
$ sed -i '/test/d' /var/log/Xorg.1.log.old
sed: /var/log/Xorg.1.log.old
The patch below seems to fix the issue for me:
$ ./sed -i '/test/d' /var/log/Xorg.1.log.old
sed: /var/log/Xorg.1.log.old: Permission denied
Regards,
Michael
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/sed/main.c,v
retrieving revision 1.30
diff -u -p -r1.30 main.c
--- main.c 26 Oct 2015 22:22:56 -0000 1.30
+++ main.c 1 Jan 2016 19:17:16 -0000
@@ -374,7 +374,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag
if (len >= sizeof(tmpfname))
error(FATAL, "%s: name too long", fname);
if ((fd = mkstemp(tmpfname)) == -1)
- error(FATAL, "%s", fname);
+ error(FATAL, "%s: %s", fname, strerror(errno));
if ((outfile = fdopen(fd, "w")) == NULL) {
unlink(tmpfname);
error(FATAL, "%s", fname);