NULL is best for C as discussed - for coreutils - at:
https://bugs.gnu.org/66221#53
* bootstrap.conf: Remove dependency on nullptr.
* s/nullptr/NULL/.
This effectively reverts 93ce19f0d5a1.
The sed(1) implementations at least on Solaris and the BSD familiy OSes do
not support the -i flag, and latest POSIX 2024 still does not specify it.
* tests/find/user-group-max.sh: Avoid 'sed -i' by redirecting to
another file ERR2.
This test failed on non-Linux systems:
- On Solaris 11, the output of the native df(1) tool has a different order,
and hence the detection of a usable mount point for the test fails.
Verify that df(1) is from GNU coreutils, or fall back to 'gdf',
else skip the test.
- On a FreeBSD system where /home was a symlink to /usr/home, the code
for finding a usable mount point failed, because the symlink itself
is on the '/' file system.
Ensure that the found mount point is identical to the original test
directory like /home etc.
* tests/find/mount-vs-xdev.sh: Try harder to use a GNU df(1) tool.
Check whether the found mount point is identical to the original
directory name, thus avoiding symlinks.
Add some more tests exercising bind mounts on the same device which
should not be affected by -mount or -xdev, and tests with a loopback
file system and a bind mount from there.
* tests/find/mount-vs-xdev-bind.sh: Add test.
* tests/find/mount-vs-xdev-other-fs.sh: Likewise.
* tests/local.mk (all_root_tests): Reference them.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
* bootstrap.conf (gnulib_modules): Add nullptr.
In code, prefer nullptr to NULL where either will do.
* cfg.mk (sc_prohibit_NULL): Direct to use nullptr instead.
(begword, endword): Add regex helper macros.
Passing -files0-from several times silently overrides the previously given
file names, and only takes the last one. This behavior is quite common
and has precedence e.g. in 'du --files0-from ...'.
Add a test to document the current behavior.
* tests/find/files0-from.sh: Add a test passing -files0-from 3 times.
Discussed at:
https://sv.gnu.org/bugs/?66965
In the current implementation, GNU find accepts the operators '!', ',',
'(' and ')' with a leading dash, e.g. '-!'.
Let's issue a warning to see if anyone relies on that odd behavior.
With a later release, let's fix the parser, and not accept these anymore.
* find/parser.c (find_parser): Issue a warning in the case one of the
above operators has been passed with a leading '-'.
* tests/find/operators-wrong-with-dash.sh: Add test.
* tests/local.mk (sh_tests): Reference it.
* NEWS (Changes in find): Mention the change in behavior.
Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-03/msg00005.html
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
Similar to commit 889d001ab750 which handles vanished files better,
also fix the race for subdirectories (FTS_DNR).
Reproducer:
In average, the following produced 6-10 failures out of 1000 runs:
$ mkdir testdir
$ while :; do mkdir testdir/foo; rmdir testdir/foo; done &
$ for f in $(seq 1000); do \
find testdir -ignore_readdir_race -ls ; done >/dev/null
find: 'testdir/foo': No such file or directory
find: 'testdir/foo': No such file or directory
* find/ftsfind.c (consider_visiting): Return when FTS returned ENOENT
for FTS_DNR, i.e., unreadable directory, with -ignore_readdir_race.
* tests/find/readdir_race.sh: Add test.
* tests/local.mk (sh_tests): Reference it.
* NEWS (Bug Fixes): Amend and improve description of the previous fix.
See also https://savannah.gnu.org/bugs/?45930
To avoid that new tests copied from the template sample-test lack the
executable bit, add the executable bit to that file.
* tests/sample-test: Set executable permission bit.
A "+" only terminates -exec when it immediately follows an argument
which is exactly "{}" (and not, for example, "{}x"). This fixes
Savannah bug 66365.
* NEWS: explain this change.
* doc/find.texi: update one place which omitted the '{}' before '+'.
* find/parser.c (insert_exec_ok): consider + to be special ony if it
follows an argument which is exactly '{}'.
* tests/find/sv-bug-66365-exec.sh: test for this bug.
* tests/local.mk: add the new test file.
The libgnulib.a library isn't (necessarily) below $(top_srcdir), it's
below $(top_builddir). This fixes a bug introduced in commit
85fc8966e5912390ad220d03b188dd319c85ed1e.
Seen on GCC 14.2.0:
tests/xargs/test-sigusr.c: In function 'run_xargs':
tests/xargs/test-sigusr.c:159:43: warning: declaration of 'optarg' \
shadows a global declaration [-Wshadow]
159 | run_xargs(const char *option, const char *optarg, int send_signal)
| ~~~~~~~~~~~~^~~~~~
...
/usr/include/bits/getopt_core.h:36:14: note: shadowed declaration is here
36 | extern char *optarg;
| ^~~~~~
* tests/xargs/test-sigusr.c (run_xargs): Rename 'optarg' parameter
to 'opt_arg'.
The recent commit removed the variable 'all_tests' which is used by
sc_tests_list_consistency in cfg.mk.
* tests/local.mk (all_tests): Re-introduce and ...
(TESTS): ... use it here.
This improved message is intended to help diagnose Savannah bug #65796.
* tests/misc/help-version.sh: when the --version ouptut of some
findutils program doesn't match the value of the VERSION environment
variable during "make check", issue a more detailed error message.
The syntax-check complains:
$ make syntax-check -k
...
maint.mk: the above files do not call bindtextdomain
make: *** [maint.mk:869: sc_bindtextdomain] Error 1
...
maint.mk: the above files do not include <config.h>
make: *** [maint.mk:509: sc_require_config_h] Error 1
...
maint.mk: use EXIT_* values rather than magic number
make: *** [maint.mk:411: sc_prohibit_magic_number_exit] Error 1
...
maint.mk: found unmarked diagnostic(s)
make: *** [maint.mk:916: sc_unmarked_diagnostics] Error 1
...
make: *** [cfg.mk:111: sc_tests_list_consistency] Error 1
...
maint.mk: Please make test executable: tests/xargs/test-sigusr.c
make: *** [cfg.mk:124: sc_tests_executable] Error 1
* cfg.mk (exclude_file_name_regexp--sc_bindtextdomain): Add test-sigusr.
(exclude_file_name_regexp--sc_unmarked_diagnostics): Define with the
pattern of the test-sigusr source file.
(sc_tests_list_consistency): Strip off ".c" suffix.
(sc_tests_executable): Exempt C source from this rule.
* tests/local.mk (TEST_EXTENSIONS): Add .c sources, needed also for
sc_tests_list_consistency to work.
* tests/xargs/test-sigusr.c (#include <config.h>): Add to avoid
sc_require_config_h failure.
(verify_signal_ignored): Call exit with EXIT_FAILURE instead of 1 to
avoid sc_prohibit_magic_number_exit failure.
(verify_signal_is_fatal): Likewise.
(verify_signal_is_nonfatal_with_p): Likewise.
* tests/.gitignore (/xargs/test-sigusr): While at it, add an entry
for the built test program here.
The following syntax-check rule fails:
$ make syntax-check
...
maint.mk: Use #include <hdr.h>, not #include "hdr.h" for the above
make: *** [maint.mk:619: sc_prefer_angle_bracket_headers] Error 1
The rule suggests using '#include <header.h>' instead of
'#include "header.h"' for headers that override system headers.
See gnulib documentation, section "Style of #include statements".
* find/parser.c (#include "fnmatch.h": Change from "..." to <...> style.
* find/pred.c (#include "fnmatch.h"): Likewise.
* find/tree.c (#include "fnmatch.h"): Likewise.
* lib/system.h (#include "error.h"): Likewise.
* locate/locate.c (#include "fnmatch.h"): Likewise.
* tests/xargs/test-sigusr.c (#include "error.h"): Likewise.
If the user uses -P we're not using only POSIX options, so in that
case it is OK to handle SIGUSR1/2. Otherwise (without -P) don't
handle these signals, meaning that they could cause xargs to
terminate.
* xargs/xargs.c: set signal handlers for SIGUSR1 and SIGUSR2 only if
the -P option was used. Warn if SIGUSR1 or SIGUSR2 is not defined.
* tests/xargs/test-sigusr: a new test for this.
* tests/local.mk: build and run the new test.
* NEWS: mention these changes.
Run 'make update-gnulib-to-latest'; there have been 518 commits on gnulib
since the last update, including the update of the copyright year numbers.
* gnulib: Update to latest.
* bootstrap: Likewise.
* bootstrap-funclib.sh: Likewise.
* tests/init.sh: Likewise.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
Run 'make update-gnulib-to-latest'; there have been 219 commits on gnulib
since the last update, including the update of the copyright year numbers.
* gnulib: Update to latest.
* autogen.sh: Auto-update.
* autopull.sh: Likewise.
* bootstrap: Likewise.
* bootstrap-funclib.sh: Likewise.
* tests/init.sh: Likewise.
The number parsing of integer arguments of the -user and -group option
was limited to INT_MAX, although the data types uid_t and gid_t are
larger on many systems, including x86_64 GNU/Linux.
* find/parser.c (UID_T_MAX, GID_T_MAX): Define.
(parse_group): Use xstrtoumax directly instead of safe_atoi, and check
the returned number vs. GID_T_MAX. Simplify error handling.
While at it, fix the est_success_rate guessing.
(parse_user): Use xstrtoumax directly instead of safe_atoi, and check
the returned number vs. UID_T_MAX.
* find/getlimits.c: Add helper utility to determine platform-local
limits for uid_t and gid_t, based on 'getlimits' of GNU coreutils,
written by Padraig Brady.
* find/Makefile.am (noinst_PROGRAMS): Make 'getlimits' as such.
* cfg.mk (exclude_file_name_regexp--sc_bindtextdomain): Add getlimits.c.
* find/.gitignore (/getlimits): Add entry.
* tests/find/user-group-max.sh: Add test.
* tests/local.mk (all_tests): Reference it.
* NEWS (Bug Fixes): Mention the fix.
Reported by Jocelyn Le Sage in
https://savannah.gnu.org/bugs/?64900
The predicates -used, -amin, -cmin, -mmin, -atime, -ctime, and -mtime
dumped core via an assertion when passing a not-a-number argument.
* find/parser.c (isnan): Add define.
(get_relative_timestamp): Diagnose when the return value of xstrtod
is not-a-number. Mention the missing parsers in the description of
the function.
* tests/find/arg-nan.sh: Add test.
* tests/local.mk (all_tests): Reference it.
* NEWS (Improvements): Mention the improvement.
Reported by Jaehan Yoon in
https://savannah.gnu.org/bugs/?64717
Dash as /bin/sh apparently does not know $'\n' syntax.
* tests/xargs/verbose-quote.sh: Define NL variable for newline character;
change from $'\n' syntax to the above variable when generating input
for xargs.
Fixes https://sv.gnu.org/bugs/?63934
There have been 626 commits on gnulib since the last update.
* bootstrap: Auto-update.
* bootstrap-funclib.sh: Likewise.
* gnulib: Update to latest.
* tests/init.sh: Likewise.
The error diagnostic for wrong invocations with option that require
numeric arguments (-inum, -links, -gid, -uid) was wrong and not helpful:
$ find -gid
find: invalid argument `-gid' to `-gid'
* find/parser.c (parse_gid): Remove changing back of the ARG_PTR in
the error case; thus simplify.
(parse_inum,parse_links,parse_uid): Likewise.
(get_num): While at it, mention -gid and -uid in the comment as well.
(insert_num): Also improve the error diagnostic in the case the user
has provided a non-numeric argument. Previously, it was just "invalid
argument".
* tests/find/opt-numeric-arg.sh: Add test.
* tests/local.mk: Reference it.
* NEWS (Bug Fixes): Mention the fix.
Reported by Andreas Schwab <schwab@linux-m68k.org> in
<https://lists.gnu.org/r/bug-findutils/2023-01/msg00001.html>
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
Run 'make update-gnulib-to-latest', mainly to update the copyright
year numbers with:
> maint: run 'make update-copyright'
This also pulls in the splitting of bootstrap into autopull.sh,
autogen.sh and bootstrap.
* autogen.sh: Add file.
* autopull.sh: Likewise.
* bootstrap-funclib.sh: Likewise.
* bootstrap: Auto-update.
* gnulib: Update to latest.
* tests/init.sh: Sync from 'gnulib/tests/init.sh'.
* tests/find/newer.sh: Add to improve test coverage.
* tests/local.mk (all_tests): Reference the test.
Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
Copyright-paperwork-exempt: Yes
Although usually a pattern containing a directory separator does not match
anything, a pattern solely consisting of one '/' still does (and has to)
for the root directory "/".
* find/parser.c (check_name_arg): Omit the warning in the case the
given pattern equals "/".
find/find.1 (-name): Clarify better that the pattern "/" is valid to
match the "/" directory.
* init.cfg (find_emits_warnings_): Add utility function.
* tests/find/name-slash.sh: Add test.
* tests/local.mk (all_tests): Reference it.
* MEWS (Bug Fixes): Mention the fix.
Fixes https://savannah.gnu.org/bugs/?62227
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
The format of the copyright year number range in Texinfo files is
"YEAR1--YEAR2" now, i.e., with 2x '-'.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
Run 'make update-gnulib-to-latest', mainly to update the copyright
year numbers with:
> maint: run 'make update-copyright'
* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
* tests/init.sh: Sync from 'gnulib/tests/init.sh'.
On most modern systems like GNU/Linux, read(2)-ing from a directory file
descriptor will fail with EISDIR, but it succeeds e.g. on GNU/Hurd and
AIX-7.1/AIX-7.2.
tests/find/files0-from.sh: Skip the test case excercising a directory
argument for the -files0-from option when the system allows reading
from a directory.
On GNU/Hurd, the value 0 is a valid inode number, and is e.g. used
for /dev/console and /dev/tty. The find(1) program aborted on this
platform when the user specified the -inum test and when the search
visited such a file.
$ find /dev/null /dev/tty -inum 40799 -printf '%i:%p\n'
40799:/dev/null
find: util.c:330: get_info: Assertion `p->st_ino' failed.
Aborted
Likewise, 'find -printf %i' aborted when hitting such a file.
* find/defs.h (get_info): Remove declaration.
* find/pred.c (pred_inum): Remove the redundant assert for ST_INO
as parse_inum sets need_inum=true which ensures that the inode number
is known.
* find/util.c (get_info): Declare static, and simplify: remove the
assertions for the inode number and file type.
While at it, add condition !state.have_stat in the need_stat case
for consistency.
* tests/find/inode-zero.sh: Add test.
* tests/local.mk (all_tests): Reference it.
Problem introduced by the inum optimisation in commit 2bf001636e6.
Reported by Andrea Monaco <andrea.monaco@autistici.org> in
https://lists.gnu.org/r/bug-findutils/2021-12/msg00008.html
Do no longer output an error diagnostic when the input file of
the -files0-from option is empty.
* find/ftsfind.c (process_all_startpoints): Remove error diagnostic.
* doc/find.texi (node Starting points): Adjust documentation.
* find/find.1: Likewise.
* tests/find/files0-from.sh: Adjust test.
Suggested by Stephane Chazelas in
https://savannah.gnu.org/bugs/?60383#comment11
Run 'make update-gnulib-to-latest' - thus pulling in 357 commits,
including the following which was also discussed in:
https://savannah.gnu.org/bugs/?60383
> test-framework-sh: remove unsafe entries from PATH
* gnulib: Update to latest.
* cfg.mk (local-checks-to-skip): Add and therefore disable sc_indent
as auto indent is too invasive for now.
* m4/mkinstalldirs.m4: Fix repeated word: s/can can/can/. Reported by
a new rule in sc_prohibit_doubled_word.
* m4/noreturn.m4: Likewise.
* tests/init.sh: Likewise.
The FTS-based find is the default for a long time; oldfind has not been
installed since 4.5.18 (2015), and was only just used in tests.
* NEWS: Document the change.
* doc/find-maint.texi (Factor Out Repeated Code): Remove mentioning of
oldfind.
* find/.gitignore (/oldfind): Remove entry.
* find/Makefile.am (check_PROGRAMS): Remove.
(oldfind_SOURCES): Remove.
* find/defs.h (struct dir_id): Remove, it was only used in oldfind.c.
(symlink_handling): Likewise.
Adjust comments wrt oldfind otherwise.
* find/oldfind.c: Remove.
* find/testsuite/config/unix.exp: Remove the code to search for and
to run tests with oldfind.
* find/testsuite/find.posix/dotdotfiles.exp: Adjust comment.
* po/POTFILES.in (find/oldfind.c): Remove entry.
* tests/find/debug-missing-arg.sh: Remove run with oldfind.
* tests/find/exec-plus-last-file.sh: Likewise.
* tests/find/execdir-fd-leak.sh: Likewise.
* tests/find/many-dir-entries-vs-OOM.sh: Likewise.
* tests/find/name-lbracket-literal.sh: Likewise.
* tests/find/printf_escape_c.sh: Likewise.
* tests/find/printf_escapechars.sh: Likewise.
* tests/find/printf_inode.sh: Likewise.
* tests/find/refuse-noop.sh: Likewise.
* tests/find/type_list.sh: Likewise.
* tests/local.mk (built_programs): Remove oldfind from list.
Prompted by the following warning of GCC-11.1.1:
tree.c: In function 'get_expr':
tree.c:140:31: warning: dereference of NULL 'prev_pred' [CWE-476] \
[-Wanalyzer-null-dereference]
140 | if ((UNI_OP == prev_pred->p_type
| ~~~~~~~~~^~~~~~~~
Former versions of find are not vulnerable to this, because a closing
parenthesis ')' without anything before was treated as a pathname
rather than an option.
But this is possible now with the recent introduction of the -files0-from
option (see commit 11576f4e6a) - yet still an invalid invocation.
Reproducer for a crash:
$ find -files0-from FILE ')' -print
Segmentation fault (core dumped)
In the similar case when the user didn't specify any action, and find(1)
adds the default action via '( user-expr ) -print', the error diagnostic
was very confusing, too:
$ find -files0-from FILE ')'
find: invalid expression; empty parentheses are not allowed.
* find/tree.c (get_expr): Handle the cases when there's no predicate
before CLOSE_PAREN, and output a useful error diagnostic.
* tests/find/files0-from.sh: Add a test case for it.
* bootstrap.conf (gnulib_modules): Add argv-iter and same-inode.
* find/defs.h (struct options): Add files0_from and ok_prompt_stdin
members.
* find/ftsfind.c (argv-iter.h, same-inode.h, xalloc.h): Add #include
for gnulib headers.
(process_all_startpoints): Change loop over starting point arguments
to a loop using the argv_iter gnulib module.
* find/parser.c (parse_table): Add option.
(parse_files0_from): Declare and define function.
(insert_exec_ok): Set options flag ok_prompt_stdin to true for
the -ok and -okdir action.
* find/util.c (usage): Add new option.
(set_option_defaults): Initialize new struct members.
* doc/find.texi (node Starting points): Add new section describing
the regular processing of starting points, and that with the new
option. Also mention in the description of -ok and -okdir that they
conflict with the new option.
* find/find.1: Document the new option here as well.
* tests/find/files0-from.sh: Add test.
* tests/local.mk (all_tests): Reference it.
* NEWS (New features in find): Mention the new option.
* xargs/xargs.c (warn_mutually_exclusive): Add function to output the
new warning diagnostic.
(main): Call the above new function in order to show a warning message
if conflicting options (-L -l -I -i -n) are specified.
* xargs/xargs.1: Explicitly document the fact that -L -l -I -i -n
options are mutually exclusive and how xargs behaves when more than one
of these options are specified.
* doc/find.texi (node Conflicting xargs options): Likewise, add this
section with examples.
* xargs/testsuite/config/unix.exp (xargs_start): Replace the full path
of the xargs executable in the stderr output file by its basename.
* xargs/testsuite/xargs.gnu/P3-n1-IARG.xe: Add file containing the
expected output with the new warning diagnostic.
* xargs/testsuite/xargs.posix/L2-n2.xe: Likewise.
* xargs/testsuite/xargs.posix/rc-123.xe: Likewise.
* xargs/testsuite/xargs.sysv/l1n4.xe: Likewise.
* xargs/testsuite/xargs/testsuite/xargs.gnu/P3-n1-IARG.exp: Ensure the
error diagnostic is in C locale to avoid false positives in other locales.
* xargs/testsuite/xargs.posix/L2-n2.exp: Likewise.
* xargs/testsuite/xargs.posix/rc-123.exp: Likewise.
* xargs/testsuite/xargs.sysv/l1n4.exp: Likewise.
* tests/xargs/conflicting_opts.sh: Add test coverage for combinations
of the mutually exclusive options -I -L and -n.
* xargs/testsuite/Makefile.am (EXTRA_DIST_EXP): Reference the new tests.
(EXTRA_DIST_XO): Reference the new *.xo files.
(EXTRA_DIST_XE): Reference the new *.xe files.
* NEWS (Improvements): Mention the change.
Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
Discussed at https://savannah.gnu.org/bugs/?52137
Duplicate of https://savannah.gnu.org/bugs/?58156
'ls -i' outputs leading blanks before the inode number on Solaris 11.
The 'exp' reference file should not contain them.
* tests/find/printf_inode.sh (make_canonical): Strip off leading
blanks.