summaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorLines
2026-05-15maint: chroot: remove unnecessary root-dev-ino.h includeCollin Funk-1/+0
The only use of this header was removed in commit d52092958 (chroot: call chroot() unconditionally to handle bind mounted "/", 2014-10-15). * src/chroot.c: Don't include root-dev-ino.h.
2026-05-15maint: expr: remove unnecessary xstrtol.h includeCollin Funk-1/+0
It has not been needed since commit 130464448 (maint: use Gnulib libgmp module, 2020-07-07). * src/expr.c: Don't include xstrtol.h.
2026-05-15maint: basenc: remove unnecessary xdectoint.h includeCollin Funk-1/+0
The only use of this header was removed in commit 97d8dcc5c (basenc: prefer signed to unsigned integers, 2021-08-27). * src/basenc.c: Don't include xdectoint.h.
2026-05-15maint: shred: remove unnecessary setjmp.h includeCollin Funk-1/+0
It has not been needed since commit 9fd2c631b (Remove all uses of signals; modern hosts have /dev/random and don't need this gorp., 2005-04-09). * src/shred.c: Don't include setjmp.h.
2026-05-13doc: shred: mention unsupported file typesCollin Funk-0/+5
* src/shred.c (usage): Mention the behavior of 'shred' on FIFOs, sockets, and terminals. * doc/coreutils.texi (shred invocation): Likewise. Addresses https://bugs.gnu.org/30177
2026-05-10maint: pacify GCC 16 -Wuseless-castPaul Eggert-20/+25
This mostly either removes casts if they are always no-ops, or replaces casts (TYPE)(EXPR) with compound literals (TYPE){EXPR}. Compound literals are a bit safer anyway, as casts are too powerful in C. * src/cksum_avx2.c (cksum_avx2): * src/cksum_avx512.c (cksum_avx512): * src/cksum_crc.c (cksum_slice8): * src/cksum_pclmul.c (cksum_pclmul): * src/cp-hash.c (remember_copied): * src/numfmt.c (simple_strtod_float): * src/system.h (x_timestyle_match): Omit no-op casts. * src/cp-hash.c (src_to_dest_hash): * src/dd.c (dd_copy): * src/df.c (devlist_hash): * src/env.c (splitbuf_append_byte): * src/getlimits.c (print_int, main): * src/ls.c (dev_ino_hash): * src/truncate.c (do_ftruncate): Replace casts with compound literals. * src/factor.c: Ignore -Wuseless-cast, as we include the imported longlong.h file, which has many of them. * src/numfmt.c (powerld): 2nd arg is now ptrdiff_t, not int, so that integers are not silently mishandled in outlandish cases.
2026-05-10shred: don't block when opening FIFOs with no readersCollin Funk-7/+19
* NEWS: Mention the bug fix. * src/shred.c (wipefile): Open the file with O_NONBLOCK. * tests/shred/fifo.sh: New file. * tests/local.mk (all_tests): Add the new test.
2026-05-09doc: date: group format sequences by functionPádraig Brady-40/+55
* src/date.c (usage): Grouping alphabetically is less useful. Suggested by Bruno Haible.
2026-05-08doc: date: show examples for format sequences in --helpPádraig Brady-46/+124
* src/date.c (usage): Show example to aid scanning of format sequences.
2026-05-07shuf: prefer fwrite over fputs and fputcCollin Funk-6/+17
On an AMD Ryzen 7 3700X running GNU/Linux: $ timeout 30 taskset 1 ./src/shuf-prev \ -r -i 1000000-1000000 | pv -r > /dev/null [ 302MiB/s] $ timeout 30 taskset 1 ./src/shuf \ -r -i 1000000-1000000 | pv -r > /dev/null [ 434MiB/s] * src/shuf.c (print_number): New function. (write_permuted_numbers, write_random_numbers): Use it. * tests/shuf/shuf.sh: Add a test case to run 'shuf -i' with varying numbers of digits to check that the string conversion is correct.
2026-05-04ls: exclude newline from consideration in line widthPádraig Brady-3/+5
* src/ls.c (calculate_columns): Treat width as inclusive max. (print_with_separator): Likewise. Also handle commas explicitly, since they're not catered for by an implicit newline in the count. * tests/ls/w-option.sh: Adjust exact-fit column tests. Note this change also makes the existing `ls -w4 -x -T0 a b` test behave consistently with other output width limits. Also add the test case from: https://github.com/coreutils/coreutils/pull/213 * tests/ls/m-option.sh: Add a test case to ensure appropriate wrapping when trailing comma at the line limit. * NEWS: Mention the change in behavior.
2026-05-04ls: fix too few display columns edge casePádraig Brady-4/+5
In the edge case where the right most column would consist of only files taking 1 or 2 cells, we accounted for 3 cells, which would result in using 1 column too few. This should have been part of commit v8.24-59-ge71be1292 * src/ls.c (init_column_info): Don't account for separator in the the final column. * tests/ls/w-option.sh: Add a test case.
2026-04-30sum,cksum: consistently emit detailed write errorsCollin Funk-3/+2
Previously the string from strerror would only be printed for some algorithms: $ cksum -a sha2 -l 256 /dev/null > /dev/full cksum: write error: No space left on device $ cksum -a sysv /dev/null > /dev/full cksum: write error This patch fixes it so that the error information is always printed: $ ./src/cksum -a sha2 -l 256 /dev/null > /dev/full cksum: write error: No space left on device $ ./src/cksum -a sysv /dev/null > /dev/full cksum: write error: No space left on device * src/cksum.c (output_file): Don't check for a write error here. (main): Check for it here instead. * tests/misc/io-errors.sh: Add a 'cksum' invocation for each supported algorithm. https://github.com/coreutils/coreutils/issues/258
2026-04-30test: adjust -g description in --helpMax Downey Twiss-1/+1
This matches the manual, as well as the -u option, and should help reduce confusion. * src/test.c (usage): Fix -g documentation to match the structure of -u
2026-04-29unexpand: fix heap overflowPádraig Brady-1/+1
* src/unexpand.c (unexpand): Use xinmalloc() to gracefully handle overflow. Also use the runtime locale specific MB_CUR_MAX rather than the worst case MB_LEN_MAX. * tests/unexpand/mb.sh: Add a test case that fails in a default glibc build with either MB_CUR_MAX or MB_LEN_MAX. * NEWS: Mention the bug fix. Reported by Michał Majchrowicz.
2026-04-29unexpand: consolidate error messagesPádraig Brady-1/+1
* src/unexpand.c (main): Use the same error as in parse_tab_stops().
2026-04-29cut: use MCEL_LEN_MAX rather than MB_LEN_MAXPádraig Brady-2/+2
* src/cut.c: We use the mcel interface to populate these arrays, so restrict to the mcel supported max. This is more efficient as generally stateful encodings are not used or supported.
2026-04-29sort: use more dynamic memory allocation with pipesPádraig Brady-31/+188
The default memory allocation with pipes was too passive/static, resulting in not allocating enough memory to enable threading. By dynamically reallocating the buffer when reading from unknown sized inputs we better use available memory and threads. $ time seq 10000000 -1 0 | sort-old >/dev/null real 0m16.523s user 0m16.900s sys 0m0.167s $ time seq 10000000 -1 0 | sort-old -S1G >/dev/null real 0m12.263s user 0m29.646s sys 0m0.527s $ time seq 10000000 -1 0 | sort-new >/dev/null real 0m12.994s user 0m31.266s sys 0m0.716s It also avoids the overhead of writing to temp files for modestly sized inputs. For example the following input would induce interaction with temp storage: $ seq 125000 | wc -c 763895 * src/sort.c (sort_buffer_size): Rename to ... (sort_buffer_policy): ... here, and adjust to set an initial size and limit, rather than just a size. (fillbuf): Add a POLICY parameter, and use that to call maybe_growbuf() as needed. (maybe_growbuf): Return true if POLICY dictates we should grow the buffer, and try_growbuf() was able to reallocate the larger buffer. * tests/sort/sort-buffer-size.sh: Add a new test. * tests/local.mk: Reference new test. * NEWS: Mention the improvement. Related to https://bugs.gnu.org/10877
2026-04-28pinky: don't print output in the wrong order when fully bufferedCollin Funk-10/+9
* NEWS: Mention the bug fix. * src/pinky.c (cat_file): Prefer streams to file descriptors when writing to standard output.
2026-04-28uniq: fix read overrun with -wPaul Eggert-2/+2
Problem reported by Michał Majchrowicz. * src/uniq.c (find_field): Fix typo. * tests/uniq/uniq.pl (add_z_variants): Test for the bug.
2026-04-25doc: apply man page formatting suggestions from manpage-l10nPádraig Brady-8/+8
* src/basenc.c: Add (1) to base64 and base32 references. * src/cksum.c. Likewise for cksum references. * src/echo.c: Use "bell" in descriptions rather than BEL. * src/printf.c: Likewise. * src/id.c: Separate -u,-U,-G so marked up appropriately. Fixes https://bugs.gnu.org/80904
2026-04-25doc: remove redundant "Report translation bugs to" in --helpBruno Haible-12/+0
* configure.ac: Define PACKAGE_L10N_BUGREPORT. * man/local.mk (run_help2man): Set the IN_HELP2MAN environment variable. * src/system.h (emit_ancillary_info): Don't emit "Report any translation bugs to" line; this is already done by emit_bug_reporting_address() in version-etc.c. Fixes https://bugs.gnu.org/80886
2026-04-23dd: avoid recursive parsing of multipliersPádraig Brady-30/+54
* src/dd.c (parse_integer): Use iterative rather than recursive parsing, to avoid potential stack overflow. * tests/dd/bytes.sh: Add a test case. https://github.com/coreutils/coreutils/issues/254
2026-04-22comm: don't close standard input twiceCollin Funk-2/+4
* NEWS: Mention the bug fix. * src/comm.c (usage): Remove mention that FILE1 and FILE2 cannot both be standard input. (compare_files): Only close standard input once. * doc/coreutils.texi (comm invocation): Document the behavior of 'comm - -' which is not portable to all implementations. * tests/comm/dash-dash.sh: New file. * tests/misc/comm.pl: Move to tests/comm/comm.pl. * tests/local.mk (all_tests): Add the new test. Rename the existing test.
2026-04-17yes: make operation independent of pipe sizePádraig Brady-18/+18
* src/yes.c (splice_write): Always drain what we've written to an internal pipe, so there is no possibility of vmsplice() blocking. I.e., be defensive in the case that fcntl() fails, and our default buffer size (currently 16kiB) is larger than the pipe. https://github.com/coreutils/coreutils/issues/253
2026-04-16build: fix build failure on AIXPádraig Brady-1/+6
* m4/jm-macros.m4: AIX has a splice() function for TCP, so check for vmsplice() instead. * src/splice.h: Define HAVE_SPLICE if vmsplice available. Reported by Bruno Haible.
2026-04-16cksum: fix --length validation on 32 bit platformsPádraig Brady-1/+1
Fix an unreleased issue due to the recent change to using idx_t in commit v9.10-91-g02983e493 * src/cksum.c (main): Limit the possible return to the range supported by idx_t. Reported by Bruno Haible.
2026-04-15df: improve detection of duplicate entriesLukáš Zaoral-2/+5
Do not compare only with the latest entry for given device id but also all previously saved entries with the same id. * src/df.c (struct devlist): Add next_same_dev struct member. (filter_mount_list): Iterate over next_same_dev to find duplicates. * tests/df/skip-duplicates.sh: Add test cases. * NEWS: Mention the improvement. https://redhat.atlassian.net/browse/RHEL-5649
2026-04-11mktemp: prefer rmdir and unlink to removeCollin Funk-1/+1
This avoids the following behavior: $ strace -e silence=exit -e trace=unlink,rmdir \ mktemp -d > /dev/full unlink("/tmp/tmp.ZBuPmS9ZGD") = -1 EISDIR (Is a directory) rmdir("/tmp/tmp.ZBuPmS9ZGD") = 0 mktemp: write error: No space left on device In the above invocation we know that we created a directory, so we should not remove a regular file that must have been created by another process: $ strace -e silence=exit -e trace=unlink,rmdir \ ./src/mktemp -d > /dev/full rmdir("/tmp/tmp.hGbME1HmJr") = 0 mktemp: write error: No space left on device * src/mktemp.c (main): Prefer rmdir and unlink depending on whether we created a directory or regular file. * bootstrap.conf (gnulib_modules): Remove the remove module.
2026-04-10cat: avoid redundant pipe creation and resizingCollin Funk-20/+28
* src/cat.c (splice_cat): Don't bother resizing input as it generally doesn't help perf, and also save an fstat per input. Don't close the intermediate pipe once created, unless there is an error reading from it. Co-authored-by: Pádraig Brady <P@draigBrady.com>
2026-04-09env: avoid locking standard output for each printed variableCollin Funk-3/+5
* src/env.c (main): Use fputs and putchar instead of printf.
2026-04-09printenv: avoid locking standard output for each printed variableCollin Funk-3/+6
* src/printenv.c (main): Use fputs and putchar instead of printf.
2026-04-09maint: remove last remaining assert()Pádraig Brady-1/+1
* src/split.c (bytes_chunk_extract): Prefer affirm to assert, as it allows for better static checking when compiling with -DNDEBUG.
2026-04-09maint: cat: avoid coverity NULL dreference warningPádraig Brady-0/+3
* src/cat.c (ensure_buf_size): Affirm we won't return NULL;
2026-04-09cat: avoid memory allocation per filePádraig Brady-18/+32
* src/cat.c (main): Only resize the allocated buffer when needed, which avoids per file heap manipulation and mmap/munmap syscalls.
2026-04-09cat: fix splice() from empty inputPádraig Brady-0/+2
* src/cat.c (splice_cat): Ensure we don't retry a read() after splice() completes, as this is significant on a tty.
2026-04-08maint: touch: prefer timespec_cmpCollin Funk-4/+2
* src/touch.c (main): Use timespec_cmp instead of comparing each member of the timespec.
2026-04-07maint: cut: avoid discarded-qualifiers warningsPádraig Brady-5/+5
Seen on GCC 15.2.1 with GLIBC 2.43 on Arch Not seen on GCC 15.2.1 on GLIBC 2.42 on Fedora * src/cut.c (search_bytes): Cast the return from memchr() to avoid const propagation. (find_field_delim): Adjust the return from strstr() similarly. https://github.com/coreutils/coreutils/issues/244
2026-04-06cat: use splice if operating on pipes or if copy_file_range failsCollin Funk-16/+166
On a AMD Ryzen 7 3700X system: $ timeout 10 taskset 1 ./src/cat-prev /dev/zero \ | taskset 2 pv -r > /dev/null [1.67GiB/s] $ timeout 10 taskset 1 ./src/cat /dev/zero \ | taskset 2 pv -r > /dev/null [9.03GiB/s] On a Power10 system: $ taskset 1 ./src/yes | timeout 10 taskset 2 ./src/cat-prev \ | taskset 3 pv -r > /dev/null [12.9GiB/s] $ taskset 1 ./src/yes | timeout 10 taskset 2 ./src/cat \ | taskset 3 pv -r > /dev/null [81.8GiB/s] * NEWS: Mention the improvement. * src/cat.c: Include isapipe.h, splice.h, and unistd--.h. (splice_cat): New function. (main): Use it. * src/local.mk (noinst_HEADERS): Add src/splice.h. * src/splice.h: New file, based on definitions from src/yes.c. * src/yes.c: Include splice.h. (pipe_splice_size): Use increase_pipe_size from src/splice.h. (SPLICE_PIPE_SIZE): Remove definition, moved to src/splice.h. * tests/cat/splice.sh: New file, based on some tests in tests/misc/yes.sh. * tests/local.mk (all_tests): Add the new test.
2026-04-06build: cut: fix compilation error on non C23 compilersPádraig Brady-8/+10
* src/cut.c (main): Add curly brackets around variable declaration in case label. Reported by Bruno Haible.
2026-04-06maint: simplify c32issepPaul Eggert-1/+1
* src/system.h (c32issep): Avoid unnecessary ‘!!’.
2026-04-06maint: cut: refactor delimiter handlingPaul Eggert-44/+14
* src/cut.c: Use mcel_scanz() to parse in all cases, and avoid redundant storage of delimiter_length and the single byte delim.
2026-04-06cut: -f: fix handling of multi-byte delimiters that span buffersPádraig Brady-0/+25
* src/cut.c (cut_fields_bytesearch): Ensure up to delim_bytes -1 is left for the next refill. * tests/cut/cut.pl: Add a test case.
2026-04-06cut,fold,expand,unexpand: ensure we process all available charactersPádraig Brady-1/+1
* gl/lib/mbbuf.h: Adjust mbbuf_fill() to process full characters in the slop at the end of a read(). Previously valid characters in the last MCEL_LEN_MAX bytes were ignored until the next read(). * src/cut.c (cut_fields_bytesearch): Adjust to the new naming. * NEWS: Mention the fold(1) responsiveness fix, which was improved with the change from fread() to read(), and completed with this patch.
2026-04-05cut: -b: avoid function calls in hot loopPádraig Brady-5/+19
$ time LC_ALL=C src/cut-before -b1 sl.in >/dev/null real 0m0.115s $ time LC_ALL=C src/cut-after -b1 sl.in >/dev/null real 0m0.076s * src/cut.c (cut_bytes): Hoist the fileno() invariant outside the loop. Avoid memchr for very short lines. (search_bytes): Similar to copy_bytes() and write_bytes() helpers. Note adding code to probe 3 or 4 bytes resulted in worse register allocation. I.e. slower operation even if the input was only 2 bytes.
2026-04-05cut: fix logic issue with field delim in last byte of bufferPádraig Brady-89/+108
With field delimiter = line delimiter we need to know if there is any more data to be read, as field delimiter in the last byte of the file is treated differently. So reiterate the loop to ensure enough read()s to make the appropriate determination.
2026-04-05cut: ensure responsive input processingPádraig Brady-57/+20
* gl/lib/mbbuf.h (fill_buf): Switch from fread() to read() as the former retries read() internally to fill the buffer. * src/cut.c: Adjust accordingly, and avoid getc() interface entirely. * bootstrap.h: Depend explicitly on fseterr. This is already depended on transitively, so should not introduce new build portability issues.
2026-04-05maint: cut: rename line_in to bytes_inPádraig Brady-9/+9
* src/cut.c: We're not reading a line, rather a buffer of bytes. Suggested by Collin Funk.
2026-04-05cut: make the dependency on memchr2 explicitPádraig Brady-1/+0
* bootstrap.conf: Remove now unused getndelim2, add memchr2. * src/cut.c: Remove now unused getndelim2.h.
2026-04-05cut: combine cut_bytes_no_split and cut_charactersPádraig Brady-37/+22
per character based so merge.