72 Commits

Author SHA1 Message Date
Bernhard Voelker
c56b96a54f maint: prefer NULL to nullptr
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.
2026-01-20 23:03:54 +01:00
Bernhard Voelker
99b3365ec3 tests: avoid unportable 'sed -i'
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.
2026-01-06 10:34:37 +01:00
Bernhard Voelker
ebea22e88b tests: make new -mount test more robust
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.
2026-01-06 10:33:59 +01:00
Bernhard Voelker
04738593b4 find: add more -mount tests (check-root)
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.
2026-01-02 22:36:44 +01:00
Bernhard Voelker
0d8de87299 find: add -mount tests
* tests/find/mount-vs-xdev.sh: Add test.
* tests/local.mk (sh_tests): Reference it.
2026-01-02 22:36:42 +01:00
Bernhard Voelker
733bb9a054 maint: update copyright year number ranges
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.
2026-01-02 11:46:15 +01:00
Bernhard Voelker
93ce19f0d5 maint: prefer C23-style nullptr
* 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.
2025-11-15 19:39:43 +01:00
Collin Funk
c18bba5c59 maint: ensure that new "make syntax-check"-run sc_codespell passes
* cfg.mk (codespell_ignore_words_list): Ignore false-positives.
(exclude_file_name_regexp--sc_codespell): Skip some file names.
* NEWS: Fix typos.
* README-hacking: Likewise.
* doc/find-maint.texi: Likewise.
* doc/find.texi: Likewise.
* bootstrap.conf: Fix typos in comments.
* find/ftsfind.c: Likewise.
* find/parser.c: Likewise.
* find/print.c: Likewise.
* find/testsuite/find.gnu/exec-one-rtn-fail.exp: Likewise.
* find/testsuite/find.posix/bracket-depth.exp: Likewise.
* find/testsuite/find.posix/exec-nogaps.exp: Likewise.
* find/testsuite/find.posix/files-not-expressions1.exp: Likewise.
* find/testsuite/find.posix/files-not-expressions2.exp: Likewise.
* find/testsuite/find.posix/files-not-expressions3.exp: Likewise.
* find/util.c: Likewise.
* init.cfg: Likewise.
* lib/regextype.h: Likewise.
* lib/splitstring.h: Likewise.
* locate/locate.c: Likewise.
* locate/updatedb.sh: Likewise.
* tests/find/exec-plus-last-file.sh: Likewise.
* tests/find/files0-from.sh: Likewise.
* tests/xargs/test-sigusr.c: Likewise.
* tests/xargs/verbose-quote.sh: Likewise.
* xargs/xargs.c: Likewise.
2025-11-15 19:39:02 +01:00
Bernhard Voelker
ee500667d4 tests: add case for passing -files0-from multiple times
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
2025-04-06 16:49:12 +02:00
Bernhard Voelker
dc3365628e find: issue a warning for wrongly accepted operators like '-!'
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
2025-03-23 23:47:15 +01:00
Bernhard Voelker
f1f6471ae8 maint: update copyright year number ranges
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.
2025-01-04 11:43:53 +01:00
Bernhard Voelker
aff4e48c11 find: ignore more vanished subdirectories with -ignore_readdir_race
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
2024-12-23 12:59:24 +01:00
Bernhard Voelker
f4ec39eee0 maint: import tests/init.sh from Gnulib during bootstrap
* bootstrap.conf (bootstrap_post_import_hook): Use gnulib-tool
--copy-file to import tests/init.sh.
* tests/init.sh: Remove file.
* tests/.gitignore (/init.sh): Add entry.
* Makefile.am (update-gnulib-to-latest): Remove handling tests/init.sh.
2024-11-03 21:32:17 +01:00
Bernhard Voelker
128c5b18c9 maint: make tests/sample-test executable
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.
2024-11-03 20:04:48 +01:00
Bernhard Voelker
727d261bb8 maint: make new tests/find/sv-bug-66365-exec.sh executable
'make syntax-check' fails with:
  tests_executable
  maint.mk: Please make test executable: tests/find/sv-bug-66365-exec.sh
  make: *** [cfg.mk:129: sc_tests_executable] Error 1

* tests/find/sv-bug-66365-exec.sh: Set executable permission bit.
2024-11-03 20:04:42 +01:00
James Youngman
1dcdf3de8e find: -exec is terminated by + only if the prior arg is exactly '{}'
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.
2024-11-02 18:42:35 +00:00
James Youngman
457acfa06b Fix VPATH compilation failure for 'make check'
The libgnulib.a library isn't (necessarily) below $(top_srcdir), it's
below $(top_builddir).  This fixes a bug introduced in commit
85fc8966e5912390ad220d03b188dd319c85ed1e.
2024-10-31 15:29:07 +00:00
Bernhard Voelker
e38e2f8a36 tests: avoid -Wshadow warning
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'.
2024-09-17 22:46:58 +02:00
Collin Funk
85fc8966e5 tests: link binaries to gnulib
* tests/local.mk (AM_CPPFLAGS): Include gnulib headers.
(LDADD): Link to gnulib.

Copyright-paperwork-exempt: Yes
2024-06-24 14:35:55 +02:00
James Youngman
e178314ae3 maint: convert tabs to spaces in C source files. 2024-06-01 21:41:05 +01:00
Bernhard Voelker
d3cbfbb6d4 maint: add more file related to test-sigusr to tests/.gitignore
* tests/.gitignore (/xargs/.dirstamp): Add entry.
(/xargs/test-sigusr.o): Likewise.
2024-06-01 17:04:24 +02:00
Bernhard Voelker
7daec5921e tests: re-introduce all_tests needed by syntax-check
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.
2024-06-01 17:04:21 +02:00
James Youngman
b25f15aad7 tests: don't distribute the tests/xargs/test-sigusr binary.
There is no NEWS item for this change since this test was introduced
since the previous release.
2024-05-30 20:24:34 +01:00
James Youngman
64e9ddbd8c [check] make fail message of tests/misc/help-version.sh explicit.
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.
2024-05-26 16:58:15 +01:00
Bernhard Voelker
32132e9749 tests: avoid various syntax-check failures wrt/ test-sigusr
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.
2024-05-20 13:57:53 +02:00
Bernhard Voelker
b9c9310eec maint: avoid gnulib sc_prefer_angle_bracket_headers failure
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.
2024-05-20 13:54:38 +02:00
James Youngman
b560e3f911 [xargs] POSIX requires SIGUSR1/2 to be fatal if not blocked.
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.
2024-05-19 11:13:31 +01:00
Bernhard Voelker
be2ea9b3b4 maint: update gnulib to latest
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.
2024-04-20 13:18:39 +02:00
Bernhard Voelker
ea1abfa968 maint: update copyright year number ranges
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.
2024-01-02 09:13:29 +01:00
Bernhard Voelker
809f8dc3eb maint: update gnulib to latest
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.
2024-01-02 08:50:58 +01:00
Bernhard Voelker
3008e19df8 find: allow -user,-group to accept larger integers beyond INT_MAX
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
2023-12-30 21:01:15 +01:00
Bernhard Voelker
2841c3a82a find: diagnose NaN arguments better
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
2023-09-30 13:42:24 +02:00
Bernhard Voelker
a5b2e20d8f tests: fix FP in xargs test when /bin/sh is dash
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
2023-05-23 01:57:47 +02:00
Bernhard Voelker
cf4133e9b0 maint: update gnulib to latest
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.
2023-05-23 00:12:54 +02:00
Bernhard Voelker
4a72809272 find: fix error diagnostics of options with mandatory, numeric arguments
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>
2023-01-05 19:43:25 +01:00
Bernhard Voelker
73d020f472 maint: update copyright year number ranges
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.
2023-01-01 23:51:15 +01:00
Bernhard Voelker
f293f5da80 maint: update gnulib to latest
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'.
2023-01-01 23:51:03 +01:00
Shuiqing Zhou
3c2d824ef5 tests: add tests for the 'find -newer' family
* 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
2022-08-09 23:45:57 +02:00
Bernhard Voelker
6d2fa2c9a0 find: omit warning diagnostic for -name '/'
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
2022-04-24 13:35:49 +02:00
Bernhard Voelker
db5ec614a7 maint: update copyright year number ranges
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.
2022-01-02 18:42:35 +01:00
Bernhard Voelker
780b31ad23 maint: update gnulib to latest
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'.
2022-01-02 18:39:11 +01:00
Bernhard Voelker
71556793c1 tests: avoid FP from 'find -files0-from DIR' on certain platforms
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.
2021-12-31 02:13:56 +01:00
Bernhard Voelker
9290525c77 find: fix visiting of files with inode number Zero
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
2021-12-29 20:36:19 +01:00
Bernhard Voelker
4ddb092de6 find: allow -files0-from input file to be empty
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
2021-11-27 23:21:06 +01:00
Bernhard Voelker
0dd5eaa329 maint: update gnulib to latest
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.
2021-11-27 23:03:16 +01:00
Bernhard Voelker
5768a03ddf oldfind: remove
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.
2021-09-20 00:14:58 +02:00
Bernhard Voelker
a5659a42fa tree.c: avoid segfault with closing parenthesis ')' after -files0-from
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.
2021-08-18 08:36:37 +02:00
Bernhard Voelker
11576f4e6a find: add -files0-from option
* 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.
2021-05-08 14:13:36 +02:00
Andreas Metzler
ee402bdd3a xargs: warn on conflicting options -L, -I, -n
* 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
2021-01-07 18:28:00 +01:00
Bernhard Voelker
21e23d1e60 tests: avoid FP on Solaris 11
'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.
2021-01-07 01:20:22 +01:00