summaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorLines
2025-12-07maint: env: reduce variable scopeCollin Funk-21/+10
* src/env.c (extract_varname, parse_signal_action_params) (parse_block_signal_params, set_signal_proc_mask) (list_signal_handling, main): Declare variables where they are used instead of at the start of the function.
2025-12-07maint: nohup: reduce variable scopeCollin Funk-14/+8
* src/nohup.c (main): Declare variables where they are used instead of at the start of the function.
2025-12-07maint: sync: reduce variable scopeCollin Funk-7/+5
* src/sync.c (sync_arg, main): Declare variables where they are used instead of at the start of the function.
2025-12-07maint: pwd: reduce variable scopeCollin Funk-23/+15
* src/pwd.c (find_dir_entry, robust_getcwd): Declare variables where they are used. (logical_getcwd, main): Likewise. Constify the result of getenv, since the result cannot be modified.
2025-12-07maint: dirname: reduce variable scopeCollin Funk-5/+3
* src/dirname.c (main): Declare variables where they are used instead of at the start of the function. Prefer idx_t to size_t.
2025-12-07maint: hostid: reduce variable scopeCollin Funk-5/+1
* src/hostid.c (main): Declare variables where they are used instead of at the start of the function.
2025-12-07maint: nproc: reduce variable scopeCollin Funk-2/+2
* src/nproc.c (main): Declare variables where they are used instead of at the start of the function.
2025-12-07maint: whoami: reduce variable scopeCollin Funk-4/+2
* src/whoami.c (main): Declare variables where they are used instead of at the start of the function.
2025-12-07maint: logname: reduce variable scopeCollin Funk-3/+1
* src/logname.c (main): Declare variables where they are used instead of at the start of the function.
2025-12-07maint: basename: initialize values while declaringCollin Funk-5/+2
* src/basename.c (remove_suffix): Initialize values on the same line as their declarations.
2025-12-07shred: use gethrxtime instead of timeCollin Funk-9/+11
The gethrxtime function uses a monotonic clock if available on the system. The effect should be unnoticeable since we print --verbose information every 5 seconds, but is more correct and we already do the same in 'dd'. * src/local.mk (src_shred_LDADD): Add $(GETHRXTIME_LIB). * src/shred.c (dopass): Use xtime_t instead of time_t. Use gethrxtime instead of time.
2025-12-05pinky: promptly diagnose write errorsCollin Funk-44/+39
In some cases 'pinky' could run forever until interrupted: $ ln -s /dev/zero ~/.plan $ ln -s /dev/zero ~/.project $ timeout -v 5 pinky -l collin > /dev/full timeout: sending signal TERM to command ‘pinky’ After this change it will exit upon failing to write to standard output: $ timeout -v 5 ./src/pinky -l collin > /dev/full pinky: write error: No space left on device * src/pinky.c: Include fadvise.h, filenamecat.h, full-write.h, and ioblksize.h. (cat_file): New function. (print_entry): Check if standard output has it's error flag set after printing a user entry. (print_long_entry): Likewise. Use the new cat_file function. * NEWS: Mention the improvement.
2025-12-04build: update gnulib submodule to latestPaul Eggert-1/+1
Gnulib issymlinkat change reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2025-12/msg00044.html * bootstrap: Update from Gnulib. * src/copy.c: Include issymlinkat.h, not issymlink.h.
2025-12-02maint: don't use == on boolsCollin Funk-3/+3
* src/df.c (filter_mount_list): Adjust comment. * src/sync.c (sync_arg): Don't use == on bools. * src/pr.c (init_parameters): Likewise.
2025-12-02timeout: print the signal number 0 instead of EXITCollin Funk-1/+1
POSIX.1-2024 added sig2str but leaves the behavior when called with signal 0 unspecified. FreeBSD 15.0 does not return the signal name EXIT like Gnulib's version causing a test failure. This fixes that and changes the behavior to print 0 instead of EXIT, to avoid confusion when the program does not exit. * NEWS: Mention the change. * src/timeout.c (cleanup): Use snprintf instead of sig2str if the signal is 0. * tests/timeout/timeout.sh: Updated the expected output.
2025-12-02timeout: prioritize "timed out" exit statusPádraig Brady-0/+6
* src/timeout.c (cleanup): Reset the default exit status to EXIT_TIMEDOUT, if we have in fact received an ALARM. Otherwise we would exit with status EXIT_CANCELED if there was an issue writing --verbose output for example. This also ensures a consistent exit status with ASAN enabled, as with ASAN stderr is not explicitly closed by gnulib's close_stdout handler.
2025-11-29timeout: ensure we terminate command upon abnormal exitPádraig Brady-0/+8
* src/timeout.c (main): Use PR_SET_PDEATHSIG to ensure the child is terminated even if the parent terminates abnormally. * tests/timeout/timeout-group.sh: Add a case to ensure sending SIGKILL results in the termination of the monitored command. * NEWS: Mention the improvement.
2025-11-28du: add the short option -A corresponding to --apparent-sizeCollin Funk-6/+5
The --apparent-size option to 'du' was added in coreutils-4.5.8 (2003). FreeBSD 8.0 (2009) added the same functionality under the short option -A. This long option previously had no short option, so this patch adds -A to be compatible with FreeBSD. * NEWS: Mention the new short option. * doc/coreutils.texi: Document the short option. * src/du.c (usage): Likewise. (APPARENT_SIZE_OPTION): Remove definition. (EXCLUDE_OPTION): Define to CHAR_MAX + 1. (long_options): Use the -A short option for --apparent-size. (main): Likewise. * tests/du/apparent.sh: Test that '-b', '-A -B 1', and '--apparent-size --block-size 1' function the same.
2025-11-27maint: prefer mcel_eq to mcel_cmpCollin Funk-3/+3
* gnulib: Update submodule to latest. * bootstrap: Run ./bootstrap --bootstrap-sync * src/expr.c (mbs_logical_cspn): Use mcel_eq instead of mcel_cmp. * src/join.c (eq_tab, main): Likewise.
2025-11-26doc: date: mention --file=- reads from standard inputCollin Funk-1/+3
* src/date.c (usage): Mention that standard input will be read if DATEFILE is "-". Reported at https://bugs.debian.org/1100395
2025-11-26doc: du, sort, wc: adjust description of --files0-fromCollin Funk-4/+4
* src/du.c (usage): Remove an unnecessary "then". * src/wc.c (usage): Likewise. Add a comma after "-". * src/sort.c (usage): Likewise. Adjust the indentation to match du and wc.
2025-11-26doc: fold: clarify operation of -s in --helpPádraig Brady-1/+1
* src/fold.c (usage): The description of -s was unclear: - State that we can also break within words. - State that we split on blanks not spaces. - State that we split after the blank, not before.
2025-11-23du,ls: don’t modify getenv stringsPaul Eggert-30/+39
Fix du and ls to conform to the POSIX getenv spec, which says you can’t modify strings returned by getenv unless you put the string there directly, or used putenv. This portability bug was found by strict C23 checking using qualifier-generic functions. * bootstrap.conf (gnulib_modules): Add xmemdup0. Sort. * src/du.c (main): * src/ls.c (decode_switches): Don’t modify the string that getenv returns. Instead, use xmemdup0 if needed, and include xmemdup0.h.
2025-11-23numfmt: port to C23 qualifier-generic fnsPaul Eggert-2/+2
* src/numfmt.c (mbsmbchr): Cast results of qualifier-generic functions to char *, to port to strict C23.
2025-11-23cat: refactor struct stat usagePaul Eggert-22/+12
* src/cat.c (main): Simplify by keeping input and output struct stat in separate local vars.
2025-11-23doc: cat -E: mention ^M$ output possibilityPádraig Brady-1/+1
* src/cat.c (usage): Document the ^M$ combination which is output for \r\n line endings. Fixes https://github.com/coreutils/coreutils/issues/130
2025-11-22dd,ls,sort: prefer sigaction over signalPádraig Brady-91/+2
sigaction() is generally available and if not provided by the sigaction gnulib module. * src/dd.c [SA_NOCLDSTOP]: Delete workarounds. * src/ls.c: Likewise. * src/sort.c: Likewise. Suggested by Collin Funk.
2025-11-22csplit,ls,sort: handle a more complete set of signalsPádraig Brady-128/+96
* src/term-sig.h: A new file defining a TERM_SIG array signals. * src/local.mk: Reference the new file. * src/csplit.c: Likewise. * src/sort.c: Likewise. * src/timeout.c: Likewise. * src/ls.c: Likewise. Also handle SIGTSTP separately. * NEWS: Mention the improvement.
2025-11-22timeout: honor ignored signal dispositionsPádraig Brady-4/+25
This behavior was depended on in our trap_sigpipe_or_skip_ helper, and now that we're handling all terminating signals, we should consistently honor their ignored signal dispositions. * NEWS: Mention the change in behavior, especially in regard to shell background jobs. * src/timeout.c (sig_needs_handling): A new helper that return TRUE, for --signal, SIG_ALRM, or non ignored signals. (cleanup_install): Filter handled signals with the helper. (block_cleanup_and_chld): Likewise. * tests/timeout/timeout-group.sh: Adjust to use the now required `env --default-signal=...` wrapper to reset (auto) ignored signals. Also change the termination signal from SIGINT to SIGUSR1 to generalize the test signals not specially handled by the shell, and newly handled by timeout(1). * tests/timeout/timeout.sh: Add a test case for SIGPIPE to ensure the ignored signal disposition is honored.
2025-11-21timeout: handle all terminating signalsPádraig Brady-10/+56
* src/timeout.c (term_sig): A new global list of all signals whose default disposition is to terminate the process. (install_cleanup): Iterate over the TERM_SIG list, rather than installing the handler for a specific subset. (block_cleanup_and_chld): Likewise. * tests/timeout/timeout.sh: Add a test case for SIGPIPE. * NEWS: Mention the bug fix.
2025-11-20build: remove explicit link to CoreFoundation libs on macOSPádraig Brady-10/+0
* src/local.mk: No longer explicitly depend on @INTL_MACOS_LIBS@ as they're no longer implicitly referenced (in LIBINTL) without gettext. The old dependency was through localename-unsafe, specifically date, du through show-date() (fprintftime), and ls, pr, stat, uptime through strftime(). gnulib commit v1.0-2439-gff4b084a68 removed the localename-unsafe dependency on macOS.
2025-11-19maint: add coreutils_hardlinks to src/.gitignoreCollin Funk-0/+1
* src/.gitignore (coreutils_hardlinks): Ignore this file. It is an empty file created when --enable-single-binary=hardlinks is used to ensure hardlinks are created after the multicall binary.
2025-11-19maint: prefer MAYBE_UNUSED to void castsCollin Funk-8/+3
* src/copy.c (clone_file, set_author): Use MAYBE_UNUSED in the prototype instead of void casting the arguments.
2025-11-19build: support --enable-single-binary=hardlinksPádraig Brady-2/+14
* Makefile.am: Use ln rather than $(LN_S) for hardlinks. * configure.ac: Accept --enable-single-binary=hardlinks. * man/local.mk: In hardlink mode, explicitly add the hardlink creation rule to mandeps. Given the automake generated dependency chain, this ensures that the hardlinks are created _after_ the multicall binary, with `make all` or `make check` etc. * src/local.mk: Define the new src/coreutils_hardlinks rule, and only depend on src/coreutils_{symlinks,shebangs} if in those modes, so that hardlinks are created _after_ the multicall binary, and other link types before. * NEWS: Mention the new feature. Addresses https://github.com/coreutils/coreutils/issues/129
2025-11-17maint: use C99 initialization syntax for single-variable 'for' loopsCollin Funk-239/+148
* src/chroot.c (parse_additional_groups): Declare variable in the 'for' clause. * src/comm.c (compare_files): Likewise. * src/cp.c (re_protect): Likewise. * src/csplit.c (save_buffer, find_line, write_to_file) (split_file, main): Likewise. * src/dd.c (apply_translations, translate_buffer) (copy_with_block, main): Likewise. * src/df.c (selected_fstype, excluded_fstype, filter_mount_list) (last_device_for_mount, get_device, get_point, get_all_entries) (main): Likewise. * src/fmt.c (copy_rest, get_prefix, fmt_paragraph, put_paragraph) (put_word): Likewise. * src/fold.c (main): Likewise. * src/head.c (elide_tail_bytes_pipe, main): Likewise. * src/install.c (main): Likewise. * src/join.c (prfields, join, main): Likewise. * src/kill.c (list_signals): Likewise. * src/ls.c (main, decode_switches, parse_ls_color, patterns_match): Likewise. * src/operand2sig.c (operand2sig): Likewise. * src/pathchk.c (no_leading_hyphen, validate_file_name): Likewise. * src/pr.c (char_to_clump): Likewise. * src/printenv.c (main): Likewise. * src/ptx.c (initialize_regex, digest_break_file) (find_occurs_in_text, print_field): Likewise. * src/remove.c (mark_ancestor_dirs): Likewise. * src/seq.c (print_numbers): Likewise. * src/shred.c (do_wipefd, main): Likewise. * src/sort.c (cleanup, inittables, key_warnings, mergefps) (check_ordering_compatibility, main): Likewise. * src/split.c (closeout): Likewise. * src/stat.c (find_bind_mount, print_it, format_to_mask): Likewise. * src/stdbuf.c (set_program_path): Likewise. * src/stty.c (apply_settings, display_changed, display_all) (recover_mode, sane_mode): Likewise. * src/system.h (stzncpy): Likewise. * src/tail.c (pipe_lines): Likewise. * src/tee.c (tee_files): Likewise. * src/tr.c (look_up_char_class, get_spec_stats): Likewise. * src/users.c (list_entries_users): Likewise.
2025-11-17build: fix make dist failurePádraig Brady-3/+3
* src/local.mk: s/crc.h/cksum_crc.h/. Reported by Bruno Haible.
2025-11-17tail: add --debug to report the --follow implementationPádraig Brady-1/+26
* doc/coreutils.texi (tail invocation): Describe --debug. * src/tail.c (tail_forever, tail_forever_inotify): Output which --follow implementation is being used. * tests/tail/debug.sh: Add a new test. * tests/local.mk: Reference the new test. * NEWS: Mention the new feature.
2025-11-16maint: convert remove a K&R declarationCollin Funk-2/+1
This function is hidden unless EVAL_TRACE is defined for debugging. * src/expr.c (trace): Convert to a prototype instead of K&R definition to avoid -Werror=strict-prototypes. Make the argument const to avoid -Werror=discarded-qualifiers.
2025-11-16du: document the TIME_STYLE env variable in usageBernhard Voelker-3/+9
The impact of the TIME_STYLE environment variable on du(1) was only documented in the Texinfo manual. To avoid surprises for users, also mention TIME_STYLE in the usage text, i.e., for --help and man. Organize similar as in ls(1), but as du(1) has slightly different behavior it would be hard to share the translation. * src/du.c (usage): Shorten the description of --time-style, and refer to an additional --time-style / TIME_STYLE description below.
2025-11-16maint: tag supported options not documented in --helpPádraig Brady-7/+7
2025-11-16maint: rearrange cksum modules so main is in cksum.cPádraig Brady-2095/+2093
* src/cksum.c: -> src/cksum_crc.c * src/cksum.h: -> src/cksum_crc.h * src/digest.c: -> src/cksum.c * src/local.mk: Adjust accordingly. * cfg.mk: Likewise. * po/POTFILES.in: Likewise. * src/cksum_avx2.c: Likewise. * src/cksum_avx512.c: Likewise. * src/cksum_pclmul.c: Likewise. * src/cksum_vmull.c: Likewise.
2025-11-16wc: fix missing documentation for the --debug optionPádraig Brady-0/+3
* doc/coreutils.texi (wc invocation): Desscribe --debug. * src/wc.c (usage): Likewise. * NEWS: Mention the bug fix.
2025-11-14doc: shred: clarify what --verbose outputsPádraig Brady-1/+7
* doc/coreutils.texi (shred invocation): Give more details on what --verbose outputs, to give some indication of its utility. * src/shred.c (usage): Likewise. Also since we're changing the string, split out translations to give translators more granular translations.
2025-11-12sort: avoid pthread calls with --parallel=1Pádraig Brady-8/+18
Before this change there were the following unneeded pthread calls: $ seq 1e6 | ltrace -c -e 'pthread*' sort --parallel=1 | wc -l % time seconds usecs/call calls function ------ ----------- ----------- --------- -------------------- 39.13 0.031757 67 468 pthread_mutex_lock 37.96 0.030811 65 468 pthread_mutex_unlock 13.17 0.010691 65 162 pthread_cond_signal 2.15 0.001747 64 27 pthread_mutex_destroy 2.00 0.001620 60 27 pthread_mutex_init 0.70 0.000565 62 9 pthread_cond_destroy 0.64 0.000518 57 9 pthread_cond_init ------ ----------- ----------- --------- -------------------- 100.00 0.081159 1170 total * src/sort.c (sort): Avoid merge tree overhead when single threaded.
2025-11-12md5sum: fix --text with the MSYS2 runtimePádraig Brady-1/+1
Note the use of "rt" is non-standard, but we're restricting its use here to systems that define O_BINARY, which should invariably support "rt" mode. * src/digest.c (): Where significant, explicitly use "rt" mode with --text, as MSYS2 defaults to binary mode for fopen'd files (though not for standard streams). * NEWS: Mention the bug fix. Fixes https://github.com/coreutils/coreutils/issues/123
2025-11-12maint: fix comment re PRLFS' remotenessPádraig Brady-2/+2
* src/stat.c (human_fstype): prlfs is used in a context of separate host and guest OS, so should be treated as remote always.
2025-11-11maint: fix a comment in the generated src/fs-is-local.h fileCollin Funk-2/+2
Reported by Bruno Haible in <https://lists.gnu.org/r/coreutils/2025-11/msg00113.html>. * src/extract-magic ($magic_comment): Mention that the function returns 1 if the file system is local and 0 if it is remote.
2025-11-09nice: clamp the niceness correctly on GNU/HurdCollin Funk-0/+34
* NEWS: Mention the bug fix. * src/nice.c (MIN_ADJUSTMENT): Set to 0 on the Hurd with glibc ≤ 2.42. (MAX_ADJUSTMENT): Set to (2 * NZERO - 2) on the Hurd with glibc ≤ 2.42. (main): Clamp the niceness to be greater or equal to MIN_ADJUSTMENT and less than or equal to MAX_ADJUSTMENT. * tests/nice/nice.sh: Add some tests for the Hurd's ranges.
2025-11-08chcon: fix memory leak in error pathPádraig Brady-1/+4
* src/chcon.c (change_file_context): If compute_context_from_mask fails, free the previously allocated file_context. Fixes https://bugs.gnu.org/79780
2025-11-04maint: adjust lseek_copy to handle non zero offsetsPádraig Brady-2/+2
* src/copy-file-data.c (lseek_copy): hole_start is initialized only when ext_start == ipos. (infer_scantype): Update the hole_start initialization to the more logically correct POS, even though that init is only needed to suppress a -Wmaybe-uninitialized warning. Note gcc 15.2 at least doesn't seem to need that suppression.