diff options
-rw-r--r-- | NEWS | 9 | ||||
-rw-r--r-- | bootstrap.conf | 1 | ||||
-rw-r--r-- | doc/diffutils.texi | 3 | ||||
-rw-r--r-- | src/diff.c | 11 | ||||
-rwxr-xr-x | tests/new-file | 14 |
5 files changed, 15 insertions, 23 deletions
@@ -2,6 +2,15 @@ GNU diffutils NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Incompatible changes + + diff no longer treats a closed stdin as representing an absent file + in usage like 'diff --new-file - foo <&-'. This feature was rarely + if ever used and was not portable to POSIX platforms that reopen + stdin on exec, such as SELinux if the process underwent an AT_SECURE + transition, or HP-UX even if not setuid. + [bug#33965 introduced in 2.8] + * Noteworthy changes in release 3.7 (2018-12-31) [stable] diff --git a/bootstrap.conf b/bootstrap.conf index 48cadd4..0c9fbfe 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -67,6 +67,7 @@ stat stat-macros stat-time stdint +stdopen strcase strftime strptime diff --git a/doc/diffutils.texi b/doc/diffutils.texi index 42d3abd..3a780db 100644 --- a/doc/diffutils.texi +++ b/doc/diffutils.texi @@ -1796,8 +1796,7 @@ second position.) To do this, use the @option{--new-file} (@option{-N}) option. This option affects command-line arguments as well as files found via directory traversal; for example, @samp{diff -N a b} treats @file{a} as empty if @file{a} does not exist but -@file{b} does, and similarly @samp{diff -N - b} treats standard input -as empty if it is closed but @file{b} exists. +@file{b} does. If the older directory contains large files that are not in the newer directory, you can make the patch smaller by using the @@ -37,6 +37,7 @@ #include <progname.h> #include <sh-quote.h> #include <stat-time.h> +#include <stdopen.h> #include <timespec.h> #include <version-etc.h> #include <xalloc.h> @@ -297,6 +298,9 @@ main (int argc, char **argv) re_set_syntax (RE_SYNTAX_GREP | RE_NO_POSIX_BACKTRACKING); excluded = new_exclude (); presume_output_tty = false; + int stdopen_errno = stdopen (); + if (stdopen_errno != 0) + error (EXIT_TROUBLE, stdopen_errno, "standard file descriptors"); /* Decode the options. */ @@ -1172,13 +1176,6 @@ compare_files (struct comparison const *parent, cmp.file[f].desc = STDIN_FILENO; if (binary && ! isatty (STDIN_FILENO)) set_binary_mode (STDIN_FILENO, O_BINARY); -#ifdef __hpux - /* Recognize file descriptors closed by the parent on HP-UX. */ - int flags = fcntl (STDIN_FILENO, F_GETFL, NULL); - if (flags >= 0 && (flags & FD_CLOEXEC) != 0) - cmp.file[f].desc = ERRNO_ENCODE (EBADF); - else -#endif if (fstat (STDIN_FILENO, &cmp.file[f].stat) != 0) cmp.file[f].desc = ERRNO_ENCODE (errno); else diff --git a/tests/new-file b/tests/new-file index 4400051..e3a61da 100755 --- a/tests/new-file +++ b/tests/new-file @@ -10,12 +10,6 @@ echo a > a || fail=1 echo '0a1 > a' > exp || fail=1 -returns_ 1 diff -N - a <&- > out || fail=1 -compare exp out || fail=1 - -returns_ 1 diff --unidirectional-new-file - a <&- > out || fail=1 -compare exp out || fail=1 - returns_ 1 diff -N b - < a > out || fail=1 compare exp out || fail=1 @@ -25,14 +19,6 @@ compare exp out || fail=1 echo '1d0 < a' > exp || fail=1 -returns_ 1 diff -N a - <&- > out || fail=1 -compare exp out || fail=1 - -# With closed standard input, require an exit status of 2 -# and empty stdout. -returns_ 2 diff --unidirectional-new-file a - <&- > out || fail=1 -compare /dev/null out || fail=1 - returns_ 1 diff -N - b < a > out || fail=1 compare exp out || fail=1 |