Commit Graph
5861 Commits
Author SHA1 Message Date
Joao Matos 394427e691 tests: csplit: add a test for the fix in the previous commit
* tests/csplit/guard-input.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-11-12 22:42:06 -08:00
Pádraig Brady 6b7abe6572 tail: ensure bounded operation when appending to input
`tail -n2 in >> in` already operated in a bounded manner,
so this makes tailing from the start with `tail -n+2 in >> in`
bounded also, operating only on the original file contents
and not increasing the size of 'in' forever.

Note this bounded operation does not apply with -f.

* src/tail.c (remaining_input): A new helper to return
the limit of the original file when output is the same file.
(tail_bytes): Use the new limit from remaining_input().
(tail_lines): Likewise.
* tests/tail/append-to-input.sh: Adjust accordingly.
Note this test was failing on Alpine due to its
different buffering behavior.  We're now consistent
over all file sizes and buffering behaviour in this case.
* NEWS: Mention the improvement.
Test failure reported by Bruno Haible.
2026-11-10 21:04:45 +00:00
Pádraig Brady 110efa89e0 tests: od: fix false failure on macOS
* tests/od/od-j.sh: Read from /dev/zero again,
as macOS stops reading at OFF_T_MAX.
2026-11-10 20:30:37 +00:00
Pádraig Brady 8026b38e21 tests: env: fix false failure with sh linked to multi-call binary
* tests/env/env.sh: Avoid calling "sh" with a modified argv[0],
as e.g. with busybox providing sh, it will fail with "applet not found".
Reported by Bruno Haible.
2026-11-10 20:01:17 +00:00
Pádraig Brady c0146c7c60 tests: timeout: fix false failure with older bash
This was seen on Centos 7 at least with bash 4.2.46.

* tests/timeout/timeout.sh: Ensure the shell doesn't incorrectly
optimize itself away when there are traps in place.
Reported by Bruno Haible.
2026-11-10 17:57:23 +00:00
Pádraig Brady 9aeb2eeb0f tests: ls: fix false failure on non GLIBC systems
* tests/ls/line-separator.sh: Skip on systems that treat
U+2028 (LINE SEPARATOR), and U+2029 (PARAGRAPH SEPARATOR)
as printable.  Also since we're requiring our printf now,
use that to decouple the test from the particular shell-escape
quoting form used.
Reported by Bruno Haible.
2026-11-10 16:48:39 +00:00
Pádraig Brady f66f9b1146 cut,expand,fold,unexpand: fix handling of multi-byte with short reads
This change is performance neutral as tested with:
 $ yes $(yes eeeaae | head -n10K | paste -s -d,) | head -n10K > ll.in
 $ hyperfine src/cut{,.orig}' -f10 -w ll.in >/dev/null'

* gl/lib/mbbuf.h (mbbuf_fill): Repeat the mbbuf_topup(), i.e. the read()
if the previous run didn't read enough.  Note we add the explicit
common case short-circuit to avoid a 20% regression
for the test case above, with GCC 16.2 with -O3 -flto.
* tests/cut/mb-short-read.sh: A new test file.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-JSCMJCN2.
2026-11-10 12:52:08 +00:00
Collin Funk 9704f18343 split: don't stop reading if a single filter stops accepting input
* src/split.c (of_t): Add the done member.
(lines_rr): Set the done member for the file if the filter has an
ignorable error. Don't attempt subsequent writes if the done member for
the file is set.
* tests/split/filter.sh: Add a test case.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-NO8YC6GS.
2026-11-09 16:09:49 -08:00
Sylvestre Ledru 40d9fe3e03 tests: ls: check a too long file name is reported as "cannot access"
* tests/ls/ls-misc.pl (name-too-long): New test.
https://github.com/uutils/coreutils/pull/15699

Link: https://github.com/coreutils/coreutils/pull/456
2026-11-09 00:24:53 +00:00
Sylvestre Ledru 64ea3f0553 tests: sort: check that a -t-like operand after -- is a file
* tests/sort/sort.pl (dash-dash-t): New test.
https://github.com/uutils/coreutils/pull/15823

Link: https://github.com/coreutils/coreutils/pull/450
2026-11-09 00:24:53 +00:00
Sylvestre Ledru 99ba5d505a tests: ls: check U+2028 and U+2029 are escaped or hidden
* tests/ls/line-separator.sh: New test.
* tests/local.mk (all_tests): Reference it.
https://github.com/uutils/coreutils/pull/16040

Link: https://github.com/coreutils/coreutils/pull/457
2026-11-09 00:24:52 +00:00
Sylvestre Ledru f5ded57fbd tests: tail: check output appended to the input stops at its end
* tests/tail/append-to-input.sh: New test.
* tests/local.mk (all_tests): Reference it.
https://github.com/uutils/coreutils/pull/15066

Link: https://github.com/coreutils/coreutils/pull/455
2026-11-09 00:19:10 +00:00
Sylvestre Ledru a041593749 tests: env: check a leading '=' in attached short option values
* tests/env/env.sh: Ensure -C=DIR, -vC=DIR, -S'-C=DIR ...' and -C=
change to a directory whose name starts with '=', that -a=NAME
sets argv[0] to '=NAME', and that -u=NAME and -vu=NAME are rejected.
https://github.com/uutils/coreutils/pull/15838

Link: https://github.com/coreutils/coreutils/pull/454
2026-11-09 00:13:38 +00:00
Sylvestre Ledru 981125e918 tests: od: check -t f4 and -t f8 use %g-style output
* tests/od/od-float.sh: Ensure 0.01, 1e-05 and 10 for -t f4 and
0.1 for -t f8 are printed with the shortest digits and two-digit
exponents.
https://github.com/uutils/coreutils/pull/15889

Link: https://github.com/coreutils/coreutils/pull/453
2026-11-09 00:13:38 +00:00
Sylvestre Ledru f7c67505cb tests: uniq: check diagnostics for invalid -f, -s and -w values
* tests/uniq/uniq.pl (147, 148, 149, 150, 151): New tests.
Ensure each option has its own message and that the value
is printed as given, including empty values and spaces.
https://github.com/uutils/coreutils/pull/15971

Link: https://github.com/coreutils/coreutils/pull/452
2026-11-09 00:13:34 +00:00
Sylvestre Ledru fc65b03e3f tests: od: check T, P and E suffixes after 0 or 0x in -N
* tests/od/od-N.sh: Ensure -N accepts octal and hex values
with T, P, E, TB, PB and EB suffixes.
https://github.com/uutils/coreutils/pull/15930

Link: https://github.com/coreutils/coreutils/pull/451
2026-11-08 23:30:10 +00:00
Collin Funk 20faee4d42 split: don't create more than N input files with -n l/N and short lines
* src/split.c (lines_chunk_split): Make sure CHUNK_NO does not exceed N.
* tests/split/l-chunk.sh: Add a test case without --elide-empty-files
and with it.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-ZDDBFXXM.
2026-11-08 12:36:23 -08:00
Collin Funk 79063df078 sort: don't share compressed temp files for the same input when merging
* src/sort.c (sortlines): Don't share compressed temporary files when
the same input is given multiple times.
* tests/sort/sort-compress-hang.sh: Add a test case that would
previously hang.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-MYSN7JAW.
2026-11-08 12:01:22 -08:00
Collin Funk 5b86ff66eb cp,mv,install: exit with status 1 when creating a hole fails
* src/copy-file-data.c (sparse_copy): Return -1 when create_hole fails.
* tests/cp/fail-create-hole.sh: New file.
* tests/local.mk (all_tests): Add the new test case.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-C18OTMQ2.
2026-11-08 11:00:49 -08:00
Pádraig Brady 4188d50eb4 tests: use more robust user and group matching
* tests/chgrp/from.sh: Force numeric lookup.
* tests/chmod/setgid.sh: Likewise.
* tests/chown/basic.sh: Likewise.
* tests/chown/preserve-root.sh: Likewise.
* tests/install/install-C-immutable.sh: Likewise.
* tests/install/install-C-root.sh: Likewise.
* tests/ls/nameless-uid.sh: Likewise.
* tests/misc/traversal-missing.sh: Likewise.
* tests/misc/user.sh: Likewise.
* tests/chown/deref.sh: Likewise.  Also avoid
name lookup which may fail if they contain spaces.
* tests/chown/verbose-dangling-symlink.sh: Likewise.
* tests/chgrp/verbose-dangling-symlink.sh: Likewise.
2026-11-08 15:29:10 +00:00
Sylvestre Ledru 572be620f0 tests: chown, chgrp: check "cannot access" vs "cannot dereference"
* tests/chown/cannot-access.sh: New test.  Ensure chown and chgrp
report "cannot access" for a missing operand, a trailing slash on a
non-directory and a missing file in a directory, and "cannot
dereference" only for a dangling symlink.
* tests/local.mk (all_tests): Reference the new test.
https://github.com/uutils/coreutils/pull/15868

Link: https://github.com/coreutils/coreutils/pull/449
2026-11-08 14:39:31 +00:00
Sylvestre Ledru 9e60b07a7c tests: date: test the '+' flag more thoroughly
* tests/date/date.pl: Check that '+' adds a sign only to year
conversions (%C, %y, %Y, %G, %F) whose width or value exceeds their
usual width, that it acts like '0' on other conversions, and that a
later '-', '_' or '0' flag cancels the sign.
https://github.com/uutils/coreutils/pull/16246

Link: https://github.com/coreutils/coreutils/pull/448
2026-11-08 14:17:59 +00:00
Sylvestre Ledru e0c24f5866 tests: chmod: ensure modes containing white space are rejected
* tests/chmod/mode-whitespace.sh: New test.  Check that chmod,
mkdir -m and install -m reject mode strings with leading or trailing
white space, or white space around a ',' separator.
* tests/local.mk (all_tests): Reference the new test.
https://github.com/uutils/coreutils/pull/16193

Link: https://github.com/coreutils/coreutils/pull/447
2026-11-08 14:06:17 +00:00
Pádraig Brady 27e21ce402 tests: avoid false failures on dash 0.5.13
dash 0.5.13 to 0.5.13.5 at least has a variable expansion bug:
https://bugzilla.redhat.com/2568651
This was seen on Fedora 44 and there is no upstream dash
release with a fix yet.

* init.cfg (bad_unicode): Avoid the dash issue, by comparing
the variable expansion and skipping upon mismatch.
* tests/du/block-size.sh: Add explicit checks for expansion
on values with high bit set.
* tests/paste/multi-byte.sh: Likewise.
2026-11-08 13:59:08 +00:00
Collin Funk 8121423eda pr: fix an infinite loop with a page of leading tabs and small columns
* src/pr.c: Continue processing if the line is truncated instead of
returning early. Return after handling headers, line numbers, etc., but
before printing the truncated clump.
* tests/pr/inf-loop.sh: New file.
* tests/local.mk (all_tests): Add the new test case.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-TMZPQ2AH.
2026-11-07 11:48:00 -08:00
Sylvestre Ledru a15203bb8c tests: wc: ensure -c counts all of a file when descriptors run out
Reported at https://github.com/uutils/coreutils/issues/15742

* tests/wc/page-size.sh: Add a test case.

Link: https://github.com/coreutils/coreutils/pull/446
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 0201866781 tests: printf: ensure %q quotes C1 controls in names with apostrophes
Reported at https://github.com/uutils/coreutils/issues/15810

* tests/printf/printf-quote.sh: Add a test case.

Link: https://github.com/coreutils/coreutils/pull/445
2026-11-07 12:35:10 +00:00
Sylvestre Ledru d7e639418a tests: csplit: ensure -z removes only empty files it created
Reported at https://github.com/uutils/coreutils/issues/16068

* tests/csplit/csplit.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/444
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 0f99186f24 tests: split: ensure the suffix start value is checked before reading
Reported at https://github.com/uutils/coreutils/issues/15569

* tests/split/numeric.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/443
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 3c689c7942 tests: md5sum: ensure --ignore-missing reports files it cannot open
Reported at https://github.com/uutils/coreutils/issues/15767

* tests/cksum/md5sum.pl: Add a test case.

Link: https://github.com/coreutils/coreutils/pull/442
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 1c62004b31 tests: join: ensure -i accepts input ordered by sort -f
Reported at https://github.com/uutils/coreutils/issues/15759

* tests/join/join.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/441
2026-11-07 12:35:10 +00:00
Sylvestre Ledru ee4ee881be tests: basenc: ensure --base58 decodes input of more than 1024 digits
Reported at https://github.com/uutils/coreutils/issues/15776

* tests/basenc/large-input.sh: Add a base58 round trip.

Link: https://github.com/coreutils/coreutils/pull/440
2026-11-07 12:35:10 +00:00
Sylvestre Ledru b99b178bf6 tests: unexpand: ensure unexpand accepts --first-only more than once
Reported at https://github.com/uutils/coreutils/issues/15992

* tests/unexpand/unexpand.pl: Add test case.

Link: https://github.com/coreutils/coreutils/pull/439
2026-11-07 12:35:10 +00:00
Sylvestre Ledru e376aa0507 tests: tail: ensure a count is validated even when later overridden
Reported at https://github.com/uutils/coreutils/issues/15997

* tests/tail/tail.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/438
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 42a8f28c00 tests: tail: ensure tail accepts a huge --max-unchanged-stats value
Reported at https://github.com/uutils/coreutils/issues/16007

* tests/tail/tail.pl: Add test case.

Link: https://github.com/coreutils/coreutils/pull/437
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 9fb2a03a63 tests: stat: ensure the last of stat's --printf and --format wins
Reported at https://github.com/uutils/coreutils/issues/15993

* tests/stat/stat-printf.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/436
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 5316d1ec95 tests: rm: ensure -i after -f reports a missing operand
Reported at https://github.com/uutils/coreutils/issues/15994

* tests/rm/f-then-i-no-operand.sh: New test.
* tests/local.mk: Reference the new test.

Link: https://github.com/coreutils/coreutils/pull/435
2026-11-07 12:35:10 +00:00
Sylvestre Ledru fb81c39b38 tests: split: ensure split accepts a leading '+' in the number of chunks
Reported at https://github.com/uutils/coreutils/issues/16006

* tests/split/b-chunk.sh: Add test case.

Link: https://github.com/coreutils/coreutils/pull/434
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 307bdd9441 tests: sort: ensure sort rejects -o combined with --debug
Reported at https://github.com/uutils/coreutils/issues/15998

* tests/sort/sort.pl: Add test case.

Link: https://github.com/coreutils/coreutils/pull/433
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 566aeee281 tests: realpath: ensure realpath -s -e fails on a dangling symlink
Reported at https://github.com/uutils/coreutils/issues/15996

* tests/misc/realpath.sh: Add test case.

Link: https://github.com/coreutils/coreutils/pull/432
2026-11-07 12:35:10 +00:00
Sylvestre Ledru cedefc7896 tests: readlink: ensure the last of readlink's -e, -f and -m wins
Reported at https://github.com/uutils/coreutils/issues/15995

* tests/readlink/can-e.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/431
2026-11-07 12:35:10 +00:00
Sylvestre Ledru bb0ffe17f7 tests: paste: ensure paste names the file in open and read errors
Reported at https://github.com/uutils/coreutils/issues/15983

* tests/paste/paste.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/430
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 30f5713ede tests: od: ensure od rejects an output type combined with --strings
Reported at https://github.com/uutils/coreutils/issues/15989

* tests/od/od.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/429
2026-11-07 12:35:10 +00:00
Sylvestre Ledru d6efb32a53 tests: od: ensure od prints the final offset even when an input fails
Reported at https://github.com/uutils/coreutils/issues/15990

* tests/od/od.pl: Add test case.

Link: https://github.com/coreutils/coreutils/pull/428
2026-11-07 12:35:10 +00:00
Sylvestre Ledru d004eacceb tests: numfmt: ensure unambiguous abbreviations of option values work
Reported at https://github.com/uutils/coreutils/issues/16005

* tests/numfmt/numfmt.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/427
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 5d793a1521 tests: nl: ensure nl accepts negative -v and -i values
Reported at https://github.com/uutils/coreutils/issues/15999

* tests/nl/nl.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/426
2026-11-07 12:35:10 +00:00
Sylvestre Ledru c1265262f9 tests: mkdir, mkfifo: ensure a numeric mode followed by ',' is rejected
Reported at https://github.com/uutils/coreutils/issues/16001

* tests/misc/mknod.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/425
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 68d3c16f99 tests: mkdir: ensure --context takes an optional argument
Reported at https://github.com/uutils/coreutils/issues/16002

* tests/mkdir/context-optional.sh: New test.
* tests/local.mk: Reference the new test.

Link: https://github.com/coreutils/coreutils/pull/424
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 98a6a87701 tests: sum: ensure the last of -r and -s wins
Reported at https://github.com/uutils/coreutils/issues/15986

* tests/cksum/sum.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/423
2026-11-07 12:35:10 +00:00
Sylvestre Ledru e2d537ace6 tests: mkfifo: ensure a -m value starting with '-' is accepted
Reported at https://github.com/uutils/coreutils/issues/16000

* tests/misc/mknod.sh: Add test case.

Link: https://github.com/coreutils/coreutils/pull/422
2026-11-07 12:35:10 +00:00