100 Commits
Author SHA1 Message Date
Collin Funk 9e804edddb printf: quote the ignored characters in the warning
* src/printf.c (STRTOX): Add a call to quote when printing the ignored
characters.
* tests/printf/printf.sh: Adjust an existing test case. Add another
quoting test case.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-I9I24ON7.
2026-10-27 18:16:03 -07:00
Collin Funk c242899118 nl: don't treat empty lines as headers with an empty -d argument
* src/nl.c (check_section): Add a check for a zero section delimiter
length.
* tests/nl/nl.sh: Add a test case.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-PDYYNTYZ.
2026-10-27 18:16:03 -07:00
Collin Funk a514201deb od: improve overflow detection and fix a crash when used on /dev/zero
* src/od.c (format_address_std): Add an affirm call to check that the
address is positive or equal to zero, which would have caused a
descriptive assertion in this case instead of a SIGSEGV.
(offset_add): New function.
(dump): Use it to diagnose overflows.
(dump_strings): Likewise.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-EZXPB4TK.
2026-10-26 18:01:52 -07:00
Collin Funk 5471637563 getlimits: print the limits for 'unsigned short'
* src/getlimits.c (USHRT_MIN): New macro.
(main): Print the limits for 'unsigned short'.
2026-10-25 17:20:53 -07:00
Collin Funk 7d74e197bb cp: quote directory names when --parents and --verbose are used
* src/cp.c (make_dir_parents_private): Quote the names of the directory
and the source.
* tests/cp/verbose-parents-quote.sh: New file
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-JJG3V3T9.
2026-10-25 14:32:32 -07:00
Collin Funk 074be5fae5 chown,chgrp: don't print uninitialized ownership info on dangling links
* src/chown-core.c (change_file_owner): Set the pointer to NULL if
fstatat fails.
* tests/chgrp/verbose-dangling-symlink.sh: New file.
* tests/chown/verbose-dangling-symlink.sh: New file.
* tests/local.mk (all_tests): Add the new tests.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-YYGC42VE.
2026-10-25 14:32:32 -07:00
Collin Funk 50a76c6ce0 mv: don't block when setting the SELinux security context on a FIFO
* src/selinux.c (restorecon_private): Open the file with O_NOCTTY and
O_NONBLOCK.
* tests/misc/selinux.sh: Add a test case.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-L5GJ7M7X.
2026-10-24 12:22:36 -07:00
Collin Funk e78a41cf8f tests: date: test that -u overrides the time zone when setting the time
This adds a test for the bug fixed by commit 9192fd32e (date: bring back
-u complexity with putenv, 2026-10-22).

* tests/date/date-set.sh: New file.
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug fix.
2026-10-24 12:22:36 -07:00
Collin Funk 499a55e03d cp: quote destination name when preserving ownership on symlinks fails
* src/copy.c (copy_internal): Add a missing quoteaf call.
* tests/cp/link-no-deref.sh: Invoke getlimits_ and uses_strace_. Inject
an error using 'strace' to verify the name of the destination is quoted
in the error message.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-3M3N6L8K.
2026-10-23 19:31:50 -07:00
Collin Funk aad192543e doc: dircolors: don't assume the shell starts in $HOME
* doc/coreutils.texi (dircolors invocation): Use an absolute path when
checking whether a user's .dircolors file exists in $HOME and when
loading it. Don't define a variable.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-HB2T3LWR.
2026-10-23 19:31:48 -07:00
Collin Funk 479317e6ce doc: dircolors: document reading from standard input
* src/dircolors.c (usage): Note that standard input is read when FILE is
"-".
* doc/coreutils.text (dircolors invocation): Likewise.
2026-10-23 19:31:38 -07:00
Collin Funk 2c2a1334fa factor: fix an infinite loop with some large numbers
* src/factor.c (mulredc2): Add the carry to p1, which is the high word
of a two-word integer created by summing two single-word integers and is
therefore unable to overflow, instead of using a low word r0, which may
wrap around by adding the carry.
* tests/factor/mulredc2-infloop.sh: New file.
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-CFUR0JKW.
2026-10-23 19:30:36 -07:00
Collin Funk 71a480bafa tests: factor: fix quoting of test input
* tests/factor/factor.pl: (@Tests): Wrap the input in double quotes so
the trailing space character is passed as an argument.
2026-10-21 22:00:05 -07:00
Collin Funk b919020cf5 factor: fix suffix validation on large integers
* src/factor.c (strtouuint): Return LONGINT_OVERFLOW only if all of the
characters are digits; otherwise, return LONGINT_INVALID.
* tests/factor/factor.pl: Add two test cases.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-IZ8PFQ7Q.
2026-10-21 20:00:43 -07:00
Collin Funk 6800b46c52 tests: avoid use of $abs_path_dir_
* tests/cp/preserve-gid.sh: Prefer to find the programs to test
with `cmd_exe`.
2026-10-21 12:42:50 +01:00
Collin Funk 54e1938105 tests: avoid a false failure on some systems
* tests/misc/proc-self-comm.sh: Make sure the 'coreutils' program is the
one we just built.
Reported by Bruno Haible.
2026-10-19 20:05:56 -07:00
Collin Funk f8ba084b3f stty: don't treat baud rates of (speed_t) -1 as invalid
* src/stty.c (struct speed_desc): New type, used to differentiate
between errors and (speed_t) -1.
(last_ibaud, last_obaud): Define variables as struct speed_desc instead
of speed_t.
(check_speed): Adjust uses of last_ibaud and last_obaud to their new
definitions.
(set_speed): Likewise. Use a struct speed_desc as the argument instead
of speed_t. Check for its validity using the valid member instead of
whether it is equal to (speed_t) -1.
(apply_settings): Use struct speed_desc instead of speed_t to store the
result of string_to_baud. Check for its validity using the valid member
instead of whether it is equal to (speed_t) -1.
(string_to_baud): Adjust the function to return a struct speed_desc
instead of speed_t.
* src/speedgen (value_to_baud): Likewise.
* NEWS: Mention the bug fix.

Link: https://github.com/coreutils/coreutils/issues/383
2026-10-19 18:23:56 -07:00
Collin Funk cc6a346226 stty: reduce the number of strtoul calls
$ ltrace -c ./src/stty-prev 38400 2>&1 | grep 'strtoul$' \
        | cut --output-delimiter=' ' -w -f 5-6
    4 __isoc23_strtoul
    $ ltrace -c ./src/stty 38400 2>&1 | grep 'strtoul$' \
        | cut --output-delimiter=' ' -w -f 5-6
    2 __isoc23_strtoul

* src/stty.c (set_speed): Add a baud rate parameter. Remove a call to
string_to_baud.
(apply_settings): When calling string_to_baud, save the return value and
pass it to set_speed.
2026-10-19 18:23:56 -07:00
Collin Funk 056730f7dd tests: misc: fix a false failure in paths containing spaces
* tests/misc/proc-self-comm.sh: Quote variables that contain the current
working directory, which may contain spaces. Don't set symlink_cat to a
multi-argument command invocation. Set the path before executing it.
Reported by Bruno Haible.
2026-10-18 17:43:23 -07:00
Collin Funk 1d5142dc09 all: use the basename of argv[0] for the comm value in the single binary
This preserves any program name transformations, e.g., when
--program-prefix=g is used as a configuration option, unlike commit
ef874ed6c (all: set /proc/self/comm to the program name in the single
binary, 2026-10-17).

* src/coreutils.c (launch_program): Use the last component of argv[0]
when setting the comm value using prctl (PR_SET_NAME, ...).
* tests/misc/proc-self-comm.sh: When using
--enable-single-binary=shebangs, test that the comm value preserves any
program name transformations, e.g., --program-prefix=g.
* NEWS: Adjust the NEWS entry to refer to last component of argv[0]
instead of the program name.
Suggested by Pádraig Brady.
2026-10-18 09:43:44 -07:00
Collin Funk 4886391906 doc: NEWS: mention the --enable-single-binary=symlinks comm value fix
* NEWS: Mention that the program name instead of argv[0] is used when
calling prctl (PR_SET_NAME, ...).
2026-10-16 21:16:10 -07:00
Collin Funk b5bc155d69 tests: misc: test that /proc/self/comm is properly set
This tests the fix introduced by commit ee9b9aff8 (all: set
/proc/self/comm to the program name in the single binary, 2026-10-17).

* tests/misc/proc-self-comm.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-10-16 21:12:35 -07:00
Collin Funk e3dd28f790 maint: ptx: use a stricter COUNTED_BY for the word table
* src/ptx.c (WORD_TABLE): Change the COUNTED_BY to use the length member
instead of alloc.
(digest_word_file): Increment the length before appending to the table
otherwise -fsanitize=bounds would kill the program.
2026-10-16 00:15:31 -07:00
Collin Funk 051456d414 maint: split: use COUNTED_BY for the list of open pipes
* src/split.c (open_pipes): Define as a struct containing the previously
global variables. Use COUNTED_BY.
(open_pipes_alloc, n_open_pipes): Remove variables moved into the newly
added struct.
(create): Update uses of the previously existing globals to reference
the open_pipes struct.
(closeout): Likewise. Don't decrement the pipe bounds until after we
make our final access to the last pipe in the array, to satisfy the
requirements of the COUNTED_BY attribute.
2026-10-15 17:33:05 -07:00
Collin Funk 4524916551 maint: sort: use COUNTED_BY for the list of temporary directories
* src/sort.c (temp_dirs): Define as a struct containing the previously
global variables. Use COUNTED_BY.
(temp_dir_count, temp_dir_alloc): Remove variables moved into the newly
added struct.
(create_temp_file, open_temp, main): Update uses of the previously
existing globals to reference the temp_dirs struct.
2026-10-15 17:33:05 -07:00
Collin Funk 5f2ad8da28 maint: df: refactor rows and columns to use COUNTED_BY
* src/df.c (table): Define as a struct containing the previously global
variables. Use COUNTED_BY.
(columns, ncolumns, ncolumns_alloc, nrows, nrows_alloc): Move into the
table struct.
(alloc_table_row, print_table, alloc_field, get_field_list, get_header)
(get_dev): Update uses of the previously existing globals to reference
the table struct.
2026-10-14 17:36:28 -07:00
Collin Funk ae58eee442 maint: factor: use a stricter COUNTED_BY on the list of factors
* src/factor.c (struct mp_factors): Change the COUNTED_BY to use the
nfactors member instead of nalloc.
2026-10-14 17:36:28 -07:00
Collin Funk a53cf09ca1 maint: join: use a stricter COUNTED_BY on fields
* src/join.c (struct line): Change the COUNTED_BY to use the nfields
member instead of nfields_allocated.
(extract_field): Increment the count before writing to the last field,
otherwise -fsanitize=bounds would kill the program.
2026-10-14 17:36:28 -07:00
Collin Funk 338e04d1e1 maint: remove unnecessary configure checks for libdl and dlopen
Since commit bff0e5412 (build: sort: explicitly tag libcrypto
dependency, 2026-09-06), which added a dependency on Gnulib's sd-dlopen
module, this check has been unnecessary. This can be seen by the
separate variables in Makefile.in, which have the same purpose.

    $ grep -E '^LIB_?DL' Makefile.in
    LIBDL = @LIBDL@
    LIB_DL = @LIB_DL@

* src/local.mk (src_sort_LDADD): Use $(LIBDL) instead of $(LIB_DL).
* configure.ac: Likewise. Don't check for dlopen and libdl, which Gnulib
has already done for us.
2026-10-11 13:57:19 -07:00
Collin Funk 4e7ea3638c timeout: don't fail to build with non-Linux prctl implementations
Linux 2.1.57 introduced both prctl(2) and PR_SET_PDEATHSIG(2), so the
condition before this patch is correct there. However, other systems
have a prctl function but not PR_SET_PDEATHSIG, e.g., Irix and
SerenityOS.

* src/timeout.c (main): Check that PR_SET_PDEATHSIG is defined before
using it.
2026-10-10 21:44:39 -07:00
Collin Funk 9c7cf20c3c doc: NEWS: mention the fix from the previous commit
* NEWS: Mention the crash when invoking various programs --help option
when configured with --disable-bold-man-page-references and
--disable-manual-url.
2026-10-08 21:17:26 -07:00
Collin Funk c2dd4d5d34 tests: wc: simplify construction of the input file
* tests/wc/page-size.sh: Prefer 'truncate' redirecting 'head /dev/zero'.
Suggested by Andreas Schwab.
2026-10-08 17:49:14 -07:00
Collin Funk 77e7674add tests: wc: add a test for the fix in the previous commit
* tests/wc/page-size.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-10-08 00:39:50 -07:00
Collin Funk 9a38bb9186 tests: misc: skip a test if the absolute top build dir is unsafe
Without this change, this test would fail during 'make distcheck', for
example.

* tests/misc/exec-bad-unicode.sh: Skip the test if $abs_top_builddir has
spaces or special characters.
* cfg.mk (_tb_misc): Also match tests/misc/exec-bad-unicode.sh.
Reported by Bruno Haible.
2026-10-06 20:21:43 -07:00
Collin Funk a0cec995fa tests: sum,cp: disable Unicode when executing Perl
* tests/local.mk (TESTS_ENVIRONMENT): Set PERL_UNICODE to 0.
* tests/cksum/sum-sysv.sh: Call binmode on STDOUT.
* tests/cp/copy-FMR.sh: Likewise.
* tests/cp/sparse-extents-2.sh: Likewise.
Fixes https://bugs.gnu.org/81994
2026-10-05 19:56:44 -07:00
Collin Funk 98c8b158b6 tests: make checks for $LOCALE_FR and $LOCALE_FR_UTF8 consistent
* tests/cp/non-utf8-name.sh: Check for $LOCALE_FR and $LOCALE_FR_UTF8
being empty or the string "none".
* tests/date/percent-percent.sh: Likewise.
* tests/du/block-size.sh (test_unit): Likewise.
* tests/ls/non-utf8-hidden.sh: Likewise.
* tests/mktemp/bad-unicode.sh: Likewise.
* tests/sort/sort-unique.sh: Likewise.
* tests/df/problematic-chars.sh:  Check for $LOCALE_FR_UTF8 being empty
or the string "none".
* tests/expand/mb.sh: Likewise.
* tests/fold/fold-characters.sh: Likewise.
* tests/fold/fold-nbsp.sh: Likewise.
* tests/fold/fold-spaces.sh: Likewise.
* tests/fold/fold-zero-width.sh: Likewise.
* tests/join/join-utf8.sh: Likewise.
* tests/misc/sleep.sh: Likewise.
* tests/nl/multibyte.sh: Likewise.
* tests/paste/multi-byte.sh: Likewise.
* tests/printf/printf-mb.sh: Likewise.
* tests/printf/printf-quote.sh: Likewise.
* tests/sort/sort-debug-keys.sh: Likewise.
* tests/unexpand/mb.sh: Likewise.
2026-10-04 15:31:59 -07:00
Collin Funk cf98d8e8ca tests: misc: test programs can execute invalid Unicode program names
* tests/misc/exec-bad-unicode.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-10-04 14:31:04 -07:00
Collin Funk 8555a51f2d tests: misc: avoid an unnecessary 'eval'
* tests/misc/no-fork.sh: Adjust the quoting of the printf call instead
of using 'eval'.
2026-10-04 11:24:08 -07:00
Collin Funk a2415242cb maint: ptx: silence -Wimplicit-fallthrough with clang
* src/ptx.c (matcher_error): Mark with _Noreturn.
2026-10-03 23:22:36 -07:00
Collin Funk 7fc7cf3a31 maint: pwd: use the COUNTED_BY attribute on the constructed file name
* src/pwd.c (struct file_name): Use COUNTED_BY on the buf member.
2026-10-03 15:40:46 -07:00
Collin Funk a940d3c920 maint: factor: use the COUNTED_BY attribute for the list of factors
* src/factor.c (struct mp_factors): Use COUNTED_BY on the f member.
(mp_no_factors): Use 0 instead of NULL when initializing the return
value.
2026-10-03 15:40:46 -07:00
Collin Funk f46ebfaa41 maint: od: fix -Wformat when DEBUG is defined
* src/od.c (main): Use %td instead of %d when printing an idx_t using
printf.
2026-10-02 21:46:20 -07:00
Collin Funk 6f36b64689 tests: readlink: add tests for the symbolic link infinite loop
* tests/readlink/rl-1.sh: Add tests for the 'readlink' invocations that
would cause an infinite loop before commit b66f3e4e2 (realpath: fix an
infinite loop when resolving symbolic links, 2026-09-25). Also test the
behavior without an option, which would not cause the infinite loop.
2026-09-29 20:43:15 -07:00
Collin Funk 40e0b385b7 tests: realpath: add some additional tests for symlink loops
* tests/misc/realpath.sh: Test the flags supported by 'realpath' that
would previously infinite loop before commit b66f3e4e2 (realpath: fix an
infinite loop when resolving symbolic links, 2026-09-25). Test an
invocation which would avoid the infinite loop by not touching the file.
2026-09-29 20:10:24 -07:00
Collin Funk c4b0996ee7 maint: join: use the COUNTED_BY attribute
* src/join.c (struct line): Use the COUNTED_BY attribute on the fields
member.
(struct seq): Use the COUNTED_BY attribute on the lines member.
(freeline): When setting a pointer using the COUNTED_BY attribute to
NULL, set its counter to zero.
2026-09-29 18:47:27 -07:00
Collin Funk ace92d7dc2 maint: add zstandard compressed tarballs to .gitignore
* .gitignore: Add a pattern matching zstandard compressed tarballs and
their signatures.
2026-09-25 20:41:37 -07:00
Collin Funk b66f3e4e27 realpath: fix an infinite loop when resolving symbolic links
Reported by Brian Foster in:
<https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/2161155>

* gnulib: Update to get commit b18879b9ed (canonicalize: Fix a missing
check for symlink loops., 2026-09-25)
* tests/misc/realpath.sh: Add a call to getlimits_. Add a test case.
* NEWS: Mention the bug fix.
2026-09-25 20:32:56 -07:00
Collin Funk a350264f42 maint: pacify -Wimplicit-fallthrough=5
The assert function doesn't always cause the program to exit, so it
can't be marked _Noreturn. Therefore, even affirm (false), when it
expands to assert (false), will warn about an implicit fallthrough.

* src/cut.c (main): Move the affirm (false) case to the end of the
switch statement.
* src/numfmt.c (simple_strtod_fatal): Likewise.
* src/tr.c (string2_extend): Remove the call to unreachable () default
and combine it with the affirm (false) case.
2026-09-25 17:55:11 -07:00
Collin Funk b41cbfd6cc tests: readlink: check the output with multiple files
* tests/readlink/multi.sh: Add pwd to the print_ver_ call. Check the
output of the existing tests.
2026-09-23 19:42:11 -07:00
Collin Funk 9977a36277 tests: cp: avoid a false failure in SELinux disabled containers as root
* tests/cp/capability.sh: Add a getlimits_ invocation. Allow 'cp' to
fail with ENOTSUP, which occurs when trying to copy the security.selinux
extended attribute.
2026-09-19 21:53:31 -07:00
Collin Funk 5f6c02d344 tests: ln: test --force with a missing target
* tests/ln/misc.sh: Use getlimits_. Check the behavior of 'ln -f' with a
missing target an existing file and a file where the link would be
placed.
2026-09-15 18:27:17 -07:00
Collin Funk 9d7b86ed23 maint: commit-msg: handle reparenting by Linux subreapers
* scripts/git-hooks/commit-msg ($git_pid): Define the parent process ID
at the start of the script. Use it to check if we were reparented.
2026-09-14 18:17:40 -07:00
Collin Funk 6ff3889887 tests: cp: avoid a false failure on GNU/Hurd
* tests/cp/sparse-to-pipe.sh: Use 'cp -T' to avoid opening the fifo as a
target directory, which causes GNU/Hurd to wait for a writer.
2026-09-11 23:39:57 -07:00
Collin Funk 4be9843dc9 tests: dd: fix a test that would never finish on GNU/Hurd
On GNU/Hurd, this test would get stuck in an infinite loop like the
following:

    + kill -s INFO 16535
    + sleep .01
    + kill -s INFO 16535
    + sleep .01
    + kill -s INFO 16535
    + sleep .01
    [...]

The signals being sent that frequently seem to prevent 'dd' from
performing writes, since it outputs the following during that time:

    0+0 records in
    0+0 records out
    0 bytes copied, 7161.11 s, 0.0 kB/s
    0+0 records in
    0+0 records out
    0 bytes copied, 7161.88 s, 0.0 kB/s
    [...]

* tests/dd/stats.sh: Use a larger interval between signals on GNU/Hurd.
2026-09-10 22:22:37 -07:00
Collin Funk e4a3653bc3 tests: printenv: fix a false failure on GNU/Hurd
* tests/misc/printenv.sh: Also filter out LD_ORIGIN_PATH.
2026-09-10 21:00:04 -07:00
Collin Funk 80d6d6f4e3 tests: split: avoid a hang on GNU/Hurd
* tests/split/suffix-length.sh: Don't run a test on GNU/Hurd.
2026-09-10 20:19:15 -07:00
Collin Funk 9e4b42982a tests: sort: avoid a failure on GNU/Hurd
On GNU/Hurd, file descriptor limits set via 'ulimit -n' seem to be
ineffective when set below the default:

    $ (ulimit -n; ulimit -n 512; ulimit -n; \
         tee $(seq 1024) < /dev/null; echo $?)
    1024
    512
    tee: 1022: Too many open files
    tee: 1023: Too many open files
    tee: 1024: Too many open files
    1

* tests/sort/sort-merge-fdlimit.sh: Don't fail if using 'ulimit -n' to
decrease the file descriptor limit is ineffective.
2026-09-08 23:53:25 -07:00
Collin Funk 1859316a9f tests: env: fix a false failure on GNU/Hurd
* tests/env/env.sh: Also filter out LD_ORIGIN_PATH.
2026-09-08 21:19:39 -07:00
Collin Funk 712fe02df1 tests: df: skip a test on WSL
* tests/df/skip-rootfs.sh: Test for /init which is listed as rootfs in
/proc/self/mountinfo, but tmpfs according to statfs.
Fixes https://bugs.gnu.org/65331
2026-09-07 16:23:49 +01:00
Collin Funk b2fc0baf2c doc: NEWS: fix mismatched quotation marks
* NEWS: Use '...' instead of '...`.
2026-09-04 13:57:55 -07:00
Collin Funk ea1c2b1787 printenv: don't quote output when given arguments and redirected
* src/printenv.c (main): Make sure quoting is disabled when we have
arguments and standard output is not a terminal.
* tests/misc/printenv.sh: Adjust single argument test cases. Add
multiple argument test cases.
* tests/misc/tty-quoting.sh: Add test cases to check if isatty is used.
* doc/coreutils.texi (printenvAlwaysQuoted): Remove macro.
(printenv invocation): Describe the adjusted quoting behavior.
(env invocation): Move the text from printenvAlwaysQuoted here since it
is no longer used for 'printenv'.
2026-08-31 18:15:39 -07:00
Collin Funk f188b3cc19 tests: csplit: test the behavior with an empty pattern
* tests/csplit/csplit.sh: Add a test case.
2026-08-31 17:31:08 -07:00
Collin Funk b7575a9d7b tests: mv: test the behavior of symbolic links to "."
* tests/mv/part-hardlink-symlink.sh: Add a test case.
2026-08-31 17:31:08 -07:00
Collin Funk 29933e8a5c tests: misc: test that various commands don't fork
* tests/misc/no-fork.sh: New file.
* tests/local.mk (all_tests): Add the new test.
* tests/misc/stdbuf.sh: Remove a test that is redundant with the new
test.
2026-08-28 22:10:34 -07:00
Collin Funk 5b70089a7b tests: printf: add tests for the %b specifier
* tests/printf/printf-cov.pl ($ESCAPE_CHARS, $ESCAPE_OUTPUT): New
variables derived from the existing 'escape-1' test.
(@Tests): Add some additional escaping tests and test %b.
2026-08-26 21:23:33 -07:00
Collin Funk 1ab303a901 tests: sort: check that non-blank characters aren't treated as blank
* tests/sort/sort.pl (@Tests): Add a few test cases.
2026-08-26 20:19:56 -07:00
Collin Funk 9c6b27e405 build: update gnulib submodule to latest 2026-08-25 21:51:13 -07:00
Collin Funk 24e485a883 tests: stat: fix a test failure on FreeBSD
* tests/stat/stat-nanoseconds.sh: Don't assume that we can create a file
with timestamps before the epoch.
Reported by Bruno Haible.
2026-08-25 19:34:52 -07:00
Collin Funk e92232687a tests: join: support old perl versions
The following error was seen on a Debian 6.0 virtual machine using perl
5.10.1:

    Bareword found where operator expected at \
      ./tests/join/join.pl line 327, near "tr/_/-/r"
    syntax error at ./tests/join/join.pl line 327, near "tr/_/-/r"
    Execution of ./tests/join/join.pl aborted due to compilation errors.
    FAIL tests/join/join.pl (exit status: 255)

* tests/join/join.pl: Don't use the /r modifier which was not introduced
until perl 5.13.7.
2026-08-23 22:47:19 -07:00
Collin Funk 32f109ca8e tests: pathchk: test the output to standard error for empty file names
* tests/misc/pathchk.sh: Move the existing empty file name tests to a
loop to check some additional options. Check the message printed to
standard error.
2026-08-22 19:55:33 -07:00
Collin Funk aa0c0de350 tests: stdbuf: check that a child process isn't created
* tests/misc/stdbuf.sh: Add a test case.
2026-08-20 22:56:49 -07:00
Collin Funk 6ac1d0907a tests: sort: check LC_ALL and LC_COLLATE
* tests/sort/sort-locale.sh: Also check LC_COLLATE.

Link: https://github.com/coreutils/coreutils/pull/269
2026-08-20 17:37:01 +01:00
Collin Funk b98f6d8c53 tests: prefer unified diffs when printing test failures
* tests/Coreutils.pm (_compare_files): Use 'diff -u' instead of
'diff -c'.
2026-08-18 22:12:31 -07:00
Collin Funk ffa26f0c2f tests: df: check that -k and -m are supported
* tests/df/df-output.sh: Check that the block size is correct when using
-k and -m.
2026-08-18 19:41:33 -07:00
Collin Funk 659a945217 maint: prefer xreallocarray when reallocating an array
* src/set-fields.c (set_fields): Prefer xreallocarray which will check
for unlikely overflows when multiplying the number of elements by the
size of the element.
2026-08-17 19:56:30 -07:00
Collin Funk aea03eb917 tests: cp: avoid a false failure when built with --disable-xattr
* tests/cp/capability.sh: Check that --preserve=xattr fails when
extended attributes cannot be copied. Check that --preserve=all creates
the copy successfully even if extended attributes cannot be copied.
2026-08-17 19:05:01 -07:00
Collin Funk 120093d94b stdbuf: improve error messages for invalid -i, -o, -e arguments
This adjusts the error messages to be a bit more descriptive. Here are
the previous errors:

  $ LC_ALL=C src/stdbuf-prev -o1a true
  stdbuf-prev: invalid mode '1a'
  $ LC_ALL=C src/stdbuf-prev -oa true
  stdbuf-prev: invalid mode 'a'
  $ LC_ALL=C src/stdbuf-prev -o1Z true
  stdbuf-prev: invalid mode '1Z': Value too large for defined data type

Here are the new errors:

  $ LC_ALL=C src/stdbuf -o1a true
  stdbuf: invalid suffix in -o argument '1a'
  $ LC_ALL=C src/stdbuf -oa true
  stdbuf: invalid -o argument 'a'
  $ LC_ALL=C src/stdbuf -o1Z true
  stdbuf: -o argument '1Z' too large

* src/stdbuf.c: Include xstrtol-error.h.
(parse_size): Return the error from xstrtoumax. Prefer ckd_add to check
for overflow.
(main): Prefer xstrtol_fatal to a custom error message.
2026-08-17 19:04:59 -07:00
Collin Funk 6fd17a6715 mv: emit warnings when copying extended attributes fails with ENOTSUP
* src/copy.c (copy_reg, copy_interal): Don't change the exit status if
copying extended attributes fails and we are 'mv'.
* src/copy.h (struct cp_options): Update some commentary.
* src/mv.c (cp_option_init): Enable require_preserve_xattr in the
cp_options struct.
* tests/cp/cp-mv-enotsup-xattr.sh: Check that the error is emitted when
'mv' is built with extended attribute support.
* doc/coreutils.texi (mv invocation): Mention that all errors are
emitted, but do not modify the exit status.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/13601
2026-08-16 20:09:19 -07:00
Collin Funk d458e11b2c tests: cp,mv,install: check for data loss with an empty backup suffix
* tests/misc/empty-backup-suffix.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-08-15 18:52:54 -07:00
Collin Funk 25e7da3f26 maint: prefer inline functions to maros
These macros evaluate their arguments more than once, so using them
while incrementing a pointer, for example, would introduce bugs.

* src/octhexdigits.h (isoct, fromoct, fromhex): Define as an inline
function instead of a macro.
2026-08-15 14:09:04 -07:00
Collin Funk 967b1a3d65 maint: stdbuf: pacify -Wanalyzer-out-of-bounds
Analyzer mistakenly reports that the CSWTCH lookup table can overflow
here since it cannot infer the value of C from the previously called
switch statement in main. See:
<https://gcc.gnu.org/bugzilla/PR126885>.

* src/stdbuf.c (optc_to_fileno): Add a default label with a call to
unreachable.
2026-08-14 22:04:58 -07:00
Collin Funk f5e1fd3126 tests: env,printenv: fix test failures on macOS
* tests/env/env.sh: Filter out __CF_USER_TEXT_ENCODING from the output.
Make the regex more strict.
* tests/misc/printenv.sh: Likewise.
Reported by Bruno Haible.
2026-08-10 19:25:38 -07:00
Collin Funk d4919e8389 maint: copy: document a member of struct cp_options
* src/copy.h (struct cp_options): Document the src_info member.
2026-08-08 20:30:05 -07:00
Collin Funk 786488adef build: update gnulib submodule to latest 2026-08-08 15:41:41 -07:00
Collin Funk 6bbdf02185 build: update gnulib submodule to latest 2026-08-06 19:52:35 -07:00
Collin Funk 328322ca64 printenv,env: quote problematic variables
* doc/coreutils.texi (printenvAlwaysQuoted): New macro.
(printenv invocation): Use it.
(env invocation): Use it.
* src/printenv.h: New file.
* src/local.mk (noinst_HEADERS): Add it.
(src_env_SOURCES): Likewise. Group with src_printenv_SOURCES.
(src_printenv_SOURCES): New variable.
* src/printenv.c: Include argmatch.h and printenv.h.
(main): Quote printed variable names and values.
* src/env.c: Include argmatch.h and printenv.h.
(main): Quote printed variable names and values.
* tests/misc/printenv.sh: Add test cases.
* tests/env/env.sh: Likewise. Adjust invalid UTF-8 test cases.
* NEWS: Mention the change in behavior.
2026-08-05 21:29:35 -07:00
Collin Funk 6b8c706233 test: dirname: add tests for -z
* tests/misc/dirname.pl (@Tests): Add a few test cases.
2026-08-02 11:24:43 -07:00
Collin Funk 657394655b dirname: quote problematic names on tty
* doc/coreutils.texi (terminalQuoted): New macro.
(readlink invocation, basename invocation, dirname invocation): Use it.
* src/dirname.c (quote_output): New variable.
(main): Quote output when appropriate.
* src/system.h (quoteN_mem): New macro.
* tests/misc/dirname.pl: Add test cases based on the ones added for
basename in commit e897dfd02 (basename: quote problematic names on tty,
2026-07-30). Copy some logic from tests/misc/basename.pl to test the -z
option.
* tests/misc/tty-quoting.sh: Also test dirname.
* NEWS: Mention the improvement.
2026-08-02 11:13:24 -07:00
Collin Funk e341208d06 tests: du: test --block-size with thousands separators
* tests/du/block-size.sh (test_unit): Test that the locales thousands
separator is used if we can determine it.
2026-07-31 21:54:29 -07:00
Collin Funk c4bf1d49be tests: du: test --block-size and BLOCK_SIZE
* tests/du/block-size.sh: New file.
* tests/local.mk: Add the test case.
2026-07-28 23:17:13 -07:00
Collin Funk 114aa7f1b7 tests: join: test the parsing of space separated -o formats
* tests/join/join.pl: Add some test cases.
2026-07-27 21:39:51 -07:00
Collin Funk ab6b01f40f tests: prefer require_inotify_supported_ to file system check
* tests/tail/inotify-rotate-resources.sh: Use require_inotify_supported_
instead of require_local_dir_ and the recently added check for
overlayfs.
Suggested by Pádraig Brady.
2026-07-26 16:52:54 -07:00
Collin Funk c2a2508c38 test: handle adjacent binary operators
* NEWS: Mention the bug fix.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_test_minus_ao): Exclude
NEWS.
* src/test.c (term): Treat '-a' and '-o' as strings instead of expecting
them to be valid unary operators.
* tests/test/test.pl: Add some test cases.
* tests/test/test-diag.pl: Also test the diagnostics with '-a arg'.
2026-07-26 12:44:01 -07:00
Collin Funk 54f88c7f2e tests: avoid a false ERROR when using overlayfs
* tests/tail/inotify-rotate-resources.sh: Also skip the test on
overlayfs.
2026-07-25 20:33:06 -07:00
Collin Funk 6e812858bb tests: date: check that weekdays are ignored when given an explicit date
* tests/date/date.pl: Add some test cases.
* tests/date/date-debug.sh: Test the debug output for this case.
2026-07-22 21:52:56 -07:00
Collin Funk 2db599e8b0 tests: wc: test -m in single byte and multi byte locales
* tests/wc/wc.pl ($mb_locale, $single_byte_locale): New variables.
(@mbTests): Add some test cases.
2026-07-22 18:52:55 -07:00
Collin Funk 8881342a24 build: reduce size of multi-call binary by reusing true logic
Map 'false' to reuse logic from 'true', instead of creating separate
binaries for each utility.

    $ size src/coreutils-prev
       text    data     bss     dec     hex filename
    1476092    7348 2191936 3675376  3814f0 src/coreutils-prev
    $ size src/coreutils
       text    data     bss     dec     hex filename
    1474612    7348 2191968 3673928  380f48 src/coreutils

* src/local.mk (noinst_HEADERS): Add src/true.h.
(src_false_LDADD): Organize with the rest of the reused programs. Use
$(src_true_LDADD) instead of $(LDADD).
(src_true_SOURCES, src_false_SOURCES): New variables.
* build-aux/gen-single-binary.sh (override_single): Map 'false' to
'true'.
* src/false.c: Remove file.
* po/POTFILES.in: Remove src/false.c.
* cfg.mk (_src): Match src/true-false.c and src/true-true.c.
* src/coreutils-false.c: New file.
* src/true-false.c: Likewise.
* src/true-true.c: Likewise.
* src/true.h: Likewise.
* src/true.c: Include true.h.
(EXIT_STATUS): Always define the macro to use the value of the TRUE_MODE
variable.
(PROGRAM_NAME): Likewise.
* NEWS: Mention the improvement.
2026-07-19 10:53:39 -07:00
Collin Funk 664b8663dd build: reduce size of multi-call binary by reusing test logic
Map the '[' command to which selects appropriate behavior at runtime,
rather than separate binaries for each closely related utility.

    $ size src/coreutils-prev
       text    data     bss     dec     hex filename
    1485188    7348 2191968 3684504  383898 src/coreutils-prev
    $ size src/coreutils
       text    data     bss     dec     hex filename
    1476092    7348 2191936 3675376  3814f0 src/coreutils

* src/local.mk (noinst_HEADERS): Add src/test.h.
(src___SOURCES): Remove src/lbracket.c. Add src/test.c and
src/test-lbracket.c.
(src_test_SOURCES): New variable.
(src/coreutils.h): Adjust the function name to be
single_binary_main_lbracket instead of single_binary_main__.
* build-aux/gen-single-binary.sh: Likewise. Map '[' to 'test'.
(override_single): Adjust the file name to be coreutils-lbracket.c
instead of coreutils-_.c.
* src/lbracket.c: Remove file.
* cfg.mk (_src): Don't match src/lbracket.c in the regular
expression. Match src/test-lbracket.c and src/test-test.c.
* src/coreutils-lbracket.c: New file.
* src/test-lbracket.c: Likewise.
* src/test-test.c: Likewise.
* src/test.h: Likewise.
* src/test.c: Include test.h.
(LBRACKET): Remove macro.
(PROGRAM_NAME): Use the variable TEST_MODE to determine the program
name.
(main): Use the variable TEST_MODE instead of the LBRACKET macro to
implement behavior specific to '['.
* NEWS: Mention the improvement.
2026-07-18 11:14:46 -07:00
Collin Funk 8bc9a81246 tests: paste: check the delimiter is reset for each file when -s is used
* tests/paste/paste.pl (@Tests): Add a test case.
2026-07-17 21:56:36 -07:00
Collin Funk fe186925c7 tests: join: test the behavior when given multiple -e options
* tests/join/join.pl (@tv): Add two test cases.
2026-07-13 22:38:03 -07:00