Ouch. ok nicm You can add this regress test as well:
Index: regress/usr.bin/file//Makefile =================================================================== RCS file: /cvs/src/regress/usr.bin/file/Makefile,v retrieving revision 1.7 diff -u -p -r1.7 Makefile --- regress/usr.bin/file//Makefile 1 May 2016 11:28:06 -0000 1.7 +++ regress/usr.bin/file//Makefile 28 Jun 2017 17:18:35 -0000 @@ -4,7 +4,7 @@ FILE=file REGRESS_TARGETS=t0 t1 t2 t3 t4 t5 t6 t7 \ t8 t9 t10 t11 t15 t17 t18 t19 \ - t20 t21 t22 t30 t31 t32 t33 + t20 t21 t22 t30 t31 t32 t33 stdin # .in: input file # .out: desired result @@ -17,6 +17,12 @@ all: ${REGRESS_TARGET} @echo ${*} @${FILE} ${.CURDIR}/${*}.in | \ sed -e "s@${.CURDIR}/@@" | \ + diff - ${.CURDIR}/${*}.out || \ + (echo "XXX ${*} failed" && false) + +stdin: + @echo ${*} + @${FILE} - </dev/null | \ diff - ${.CURDIR}/${*}.out || \ (echo "XXX ${*} failed" && false) Index: regress/usr.bin/file//stdin.out =================================================================== RCS file: regress/usr.bin/file//stdin.out diff -N regress/usr.bin/file//stdin.out --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ regress/usr.bin/file//stdin.out 28 Jun 2017 17:13:53 -0000 @@ -0,0 +1 @@ +/dev/stdin: empty On Wed, Jun 28, 2017 at 12:43:52PM -0400, Bryan Steele wrote: > My latest commit broke support for stdin input, whoops. > > ok? > > Index: file.c > =================================================================== > RCS file: /cvs/src/usr.bin/file/file.c,v > retrieving revision 1.62 > diff -u -p -u -r1.62 file.c > --- file.c 28 Jun 2017 15:42:49 -0000 1.62 > +++ file.c 28 Jun 2017 16:42:40 -0000 > @@ -217,12 +217,16 @@ prepare_input(struct input_file *inf, co > { > int fd, mode, error; > > + inf->path = path; > + > if (strcmp(path, "-") == 0) { > if (fstat(STDIN_FILENO, &inf->sb) == -1) { > inf->error = errno; > inf->fd = -1; > + return; > } > inf->fd = STDIN_FILENO; > + return; > } > > if (Lflag) > @@ -232,6 +236,7 @@ prepare_input(struct input_file *inf, co > if (error == -1) { > inf->error = errno; > inf->fd = -1; > + return; > } > > /* We don't need them, so don't open directories or symlinks. */ > @@ -245,7 +250,6 @@ prepare_input(struct input_file *inf, co > if (S_ISLNK(mode)) > read_link(inf, path); > inf->fd = fd; > - inf->path = path; > } > > static void >