summaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorLines
2022-09-17kill: port to picky-conversion hostsPaul Eggert-2/+3
* src/kill.c (send_signals): Don’t rely on conversion overflow being silent.
2022-09-15maint: prefer static_assert to verifyPaul Eggert-43/+46
* bootstrap.conf: Add assert-h. * gl/lib/randperm.c: Do not include verify.h. * gl/lib/randperm.c, src/basenc.c, src/dd.c, src/digest.c: * src/dircolors.c, src/expr.c, src/factor.c, src/ls.c, src/numfmt.c: * src/od.c, src/seq.c, src/shred.c, src/sort.c, src/stat.c: Prefer C23’s static_assert to nonstandard verify. * gl/modules/randperm (Depends-on): Add assert-h.
2022-09-15maint: assume C23 alignofPaul Eggert-1/+0
* gl/lib/randread.c, src/stat.c (print_statfs): No need to include stdalign.h, now that alignof is a keyword in C23 and Gnulib arranges for this.
2022-09-15maint: don’t include config.h twicePaul Eggert-3/+0
* gl/lib/fadvise.h, gl/lib/smack.h, src/blake2/blake2-impl.h: Do not include config.h from a .h file. config.h is supposed to be included once, at the start of compilation and before any other file.
2022-09-12maint: adjust to Gnulib stdbool C23 changePaul Eggert-4/+0
* gl/lib/mbsalign.c, gl/lib/randread.c, gl/lib/targetdir.h: * gl/lib/xdectoint.c, gl/lib/xfts.c, gl/lib/xfts.h: * src/blake2/b2sum.c, src/copy.h, src/die.h, src/system.h: Don’t include <stdbool.h>, since Gnulib now emulates C23.
2022-09-11stty: give explicit error for unsupported asymmetric speedsPádraig Brady-4/+30
* src/stty.c (check_speed): If difference input and output speeds are specified, then validate the system supports that, before interacting with the device.
2022-09-11stty: fix false warnings from [io]speed settingsPádraig Brady-51/+36
* src/stty.c (eq_mode): A new function to compare equivalence of two modes. (main): Use eq_mode() rather than memcmp() to compare two modes. Also use stack variables rather than implicitly initialized static variables. Also remove all uses of the SPEED_WAS_SET hack since we now more robustly compare modes. * NEWS: Update the [io]speed fix entry. Reported at https://bugs.debian.org/1019468
2022-08-31stty: add an undocumented ---debug option for more infoPádraig Brady-9/+27
* src/stty.c (main): Move internal TESTING code that showed the new and old mode, upon failure to apply the new mode, to being runtime controlled with the ---debug option. Also augment the display to show which items were not set as expected.
2022-08-31stty: validate ispeed and ospeed argumentsPádraig Brady-4/+25
* src/stty.c (apply_settings): Validate [io]speed arguments against the internal accepted set. (set_speed): Check the cfset[io]speed() return value so that we validate against the system supported set. * tests/misc/stty-invalid.sh: Add a test case. * NEWS: Mention the bug fix. Reported in https://bugs.debian.org/1018790
2022-08-29maint: be defensive in avoiding gnulib's poll modulePádraig Brady-0/+7
* src/tail.c (check_output_alive): Add a guard that would trigger on most platforms, to detect if we're using the gnulib poll module. That's currently problematic in the way it emulates poll() using select() and would cause issues on macOS and AIX at least as poll() is replaced there.
2022-08-29tail: use poll() on macOSPádraig Brady-5/+6
* src/tail.c (check_output_alive): poll() is the most commonly used interface, so use this on macOS also to minimize divergence.
2022-08-27comm: fix NUL --output-delimiter with --totalPádraig Brady-5/+16
* src/comm.c (compare_files): Handle the single character --output-delimeter case separately so that NUL is appropriately handled. * doc/coreutils.texi (comm invocation): Fix the description of --output-delimiter to say an empty delimeter is treated as a NUL separator, rather than being disallowed. * tests/misc/comm.pl: Add a test case. Reported at https://bugs.debian.org/1014008
2022-08-27maint: remove FIXME comment from timeout.cPádraig Brady-1/+1
* src/timeout.c: We shouldn't hardcode `sh -c` as users can specify that if needed, so remove the comment.
2022-08-27runcon: distinguish runcon specific errors in exit statusPádraig Brady-20/+20
* src/runcon.c: Use EXIT_CANCELED (125) instead of EXIT_FAILURE (1), so that errors specific to runcon can be distinguished, from those of the invoked program. * doc/coreutils.texi (runcon invocation): Fix the Exit status description to say we return 125 (not 127) for internal errors. * tests/misc/runcon-no-reorder.sh: Add a test case.
2022-08-13ls: support explicit --time=modification selectionPádraig Brady-1/+4
* src/ls.c [time_args]: Add support for explicit 'mtime' or 'modification' arguments to --time. * tests/misc/ls-time.sh: Add explicit --time=mtime usage. * doc/coreutils.texi (ls invocation): Describe --time=mtime. * NEWS: Mention the new feature.
2022-08-12doc: ls: clarify description of timestampsPádraig Brady-2/+2
* src/ls.c (usage): Don't mention "modification" in the description of ctime (-c), as it's confusing with mtime. Mention "metadata" when discussing "change" time to disambiguate from data change time. * doc/coreutils.texi (ls invocation): State that --time=creation falls back to using mtime where not available.
2022-07-27touch: fix aliasing bugPaul Eggert-13/+11
Problem reported by Tim Lange in: https://lists.gnu.org/r/coreutils/2022-07/msg00008.html * src/touch.c (date_relative): Rename from get_reldate, and use a functional style to fix the aliasing bug.
2022-07-26doc: env: clarify that empty signal args are ignoredPádraig Brady-1/+1
It's useful to treat empty and missing arguments differently. Missing means all signals, while empty means no signals and so is a no-op. It's useful to treat empty arguments like this, so that dynamically specified arguments like the following are supported env --ignore-signals "$SIGS_TO_IGNORE" Note `env --ignore-signals=` is treated as an empty argument. * doc/coreutils.texi (env invocation): Empty args are treated differently to missing arguments, so call that out explicitly. * src/env.c (usage): Likewise. Addresses https://bugs.debian.org/1016049
2022-07-24doc: date: clarify which options are mutually exclusivePádraig Brady-0/+5
* src/date.c (usage): Specify that --date, --file, --reference, and --resolution are mutually exclusive. This is also useful documentation to group similar options. * doc/coreutils.texi (Options for date): Likewise. Addresses https://bugs.gnu.org/55401
2022-07-24date: --debug: diagnose discarded -d or -s optionsPádraig Brady-0/+12
* src/date.c: (main): Track and diagnose whether any -d or -s options are dropped, as users may think multiple options are supported, given they can be relative. * tests/misc/date-debug.sh: Add a test case. * NEWS: Mention the improvement.
2022-07-24runcon: ensure --compute runs the file it inspectsPádraig Brady-1/+1
* src/runcon.c (main): With -c avoid searching the path to ensure the file specified to --compute is executed. * tests/misc/runcon-compute.sh: Add a new test. * tests/local.mk: Reference the new test. * NEWS: Mention the bug fix. Reported in https://bugs.debian.org/1013924
2022-07-24doc: tr: clarify that -t is ignored unless translatingPádraig Brady-1/+1
* src/tr.c (usage): Don't say that -t is disallowed unless translating. Reported in https://bugs.debian.org/1012447
2022-07-23rm: don’t assume st_size is nonnegativePaul Eggert-10/+19
* src/remove.c: Include stat-time.h. (cache_fstatat, cache_stat_init): Use negative st->st_atim.tv_sec to determine whether the stat is cached, not negative st->st_size. On non-POSIX platforms that lack st_atim.tv_sec, don’t bother to cache.
2022-07-22stat: -c %s now prints unsignedPaul Eggert-1/+9
* src/stat.c (unsigned_file_size): New static function, copied from src/ls.c. (print_stat): %s prints an unsigned value now (Bug#56710).
2022-07-06cp: don’t remove nonempty cloned destPaul Eggert-2/+10
This follows up on comments by Pádraig Brady (bug#56391). * src/copy.c (copy_reg): When --reflink=always removes a file due to an FICLONE failure, do not remove a nonempty file.
2022-07-05cp: don’t create empty file if cannot clonePaul Eggert-0/+3
* src/copy.c (copy_reg): With --reflink=always, if FICLONE fails on a file we just created, clean up by removing the file (Bug#56391).
2022-07-04maint: fix comment typoIvan Radić-1/+1
* src/uniq.c: s/preceges/precedes/
2022-06-24shuf: better diagnostic for ‘shuf -i -10-10’Paul Eggert-18/+23
* src/shuf.c: Do not include xdectoint.h. (main): Improve diagnostic for ‘shuf -i -10-10’. Without this patch, the diagnostic was “shuf: invalid input range: ‘’” which is not helpful. Now it is “shuf: invalid input range: ‘-10-10’”.
2022-06-23cp: avoid -Wmaybe-uninitialized warning from GCC13Jim Meyering-1/+6
* src/copy.c (infer_scantype): Always set scan_inference.ext_start, to make the code match the comment.
2022-06-23maint: remove unnecessary inclusion of hash.hJim Meyering-1/+0
* src/cut.c: Don't include hash.h. The implementation was changed not to need that in v8.21-43-g3e466ad05.
2022-06-11cp: fix ‘cp -rx / /mnt’Paul Eggert-27/+23
Problem reported by pkoraou@gmail.com (Bug#55910). * src/copy.c (copy_internal): Treat a relative destination name "" as if it were "." for the purpose of directory-relative syscalls like fstatat that might might refer to the destination directory.
2022-06-03maint: avoid \] in REsPaul Eggert-3/+3
* cfg.mk (sc_dd_max_sym_length, sc_prohibit_man_see_also_period): Do not rely on undefined interpretation of \] in regular expressions.
2022-05-25maint: spelling fixPaul Eggert-1/+1
2022-05-25sort: tune diff_reversedPaul Eggert-1/+1
* src/sort.c (diff_reversed): Tune. On x86-64 with GCC, this saves a conditional branch and shortens the generated machine code.
2022-05-25sort: refactor tricky diff reversalPaul Eggert-6/+11
* src/sort.c (diff_reversed): New function, to make the intent clearer. (keycompare, compare): Use it.
2022-05-25maint: sort.c: fix syntax-check issue in recent commitPádraig Brady-2/+1
* src/sort.c (keycompare): Avoid useless if before free() as detected with sc_avoid_if_before_free.
2022-05-25sort: fix issue with -rk in previous commitPádraig Brady-1/+1
* src/sort.c (keycompare): Fix typo causing -r to be effectively ignored with -k. Fixes https://bugs.gnu.org/55622
2022-05-17sort: fix unlikely int overflow with -rPaul Eggert-2/+6
* src/sort.c (keycompare, compare): Don’t overflow if -r is specified and a comparison function returns INT_MIN, as this causes the comparison to have undefined behavior (typically the reverse of correct). glibc memcmp on s390x reportedly returns INT_MIN in some cases, so this is not a purely academic issue.
2022-05-17maint: simplify comparisonsPaul Eggert-12/+10
* src/comm.c (compare_files): * src/join.c (keycmp): * src/ls.c (off_cmp): * src/ptx.c (compare_words, compare_occurs): * src/set-fields.c (compare_ranges): Prefer ((a > b) - (a < b)) to variants like (a < b ? -1 : a > b) as it’s typically faster these days.
2022-05-17sort: remove some gotosPaul Eggert-27/+28
* src/sort.c (keycompare): Rework to avoid gotos. This also shrinks the machine code a bit (112 bytes) with GCC 12 x86-64 -O2. Nowadays compilers are smart enough to coalesce jumps so we need not do it by hand.
2022-05-17sort: pacify GCC 12 false positivePaul Eggert-23/+17
* src/sort.c (keycompare): Rework to pacify a GCC 12 -Wmaybe-uninitialized false positive, by coalescing some minor duplicate code and eliminating a branch. This should execute an insn or two less in the usual case.
2022-05-09factor: --exponents: new option for printing in p^e formatRasmus Villemoes-4/+25
When factoring numbers that have a large 2^n factor, it can be hard to eyeball just how many 2's there are. Add an option to print each prime power factor in the p^e format (omitting the exponent when it is 1). * src/factor.c: Add -h, --exponents option for printing in p^e format. * doc/coreutils.texi (factor invocation): Document the new option. * tests/misc/factor.pl: Add test case. * THANKS.in: Add previous suggester (https://lists.gnu.org/r/coreutils/2017-11/msg00015.html). Suggested-by: Emanuel Landeholm <emanuel.landeholm@gmail.com> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2022-05-02tests: sort-NaN-infloop: augment testing for recent fixPádraig Brady-1/+1
* tests/misc/sort-NaN-infloop.sh: Add test case from https://unix.stackexchange.com/a/700967/37127 * src/sort.c: Avoid syntax-check failure.
2022-05-01sort: fix sort -g infloop againPaul Eggert-15/+6
Problem reported by Giulio Genovese (Bug#55212). * src/sort.c (nan_compare): To compare NaNs, simply printf+strcmp. This avoids the problem of padding bits and unspecified behavior. Args are now long double instead of char *; caller changed.
2022-04-19pr: don’t use uninitialized varPaul Eggert-3/+10
Found with -flto and --enable-gcc-warnings. * src/pr.c (getoptarg): Fix misuse of xstrtol, which does not necessarily set tmp_long on errror, and does not set errno in any reliable way. The previous code might access uninitialized storage; on typical platforms this merely causes it to possibly print the wrong diagnostic.
2022-04-17doc: rmdir: clarify --ignore-fail-on-non-empty operationPádraig Brady-6/+3
This option has changed from ignoring only ENOTEMPTY|EEXIST (i.e. ignore errors _solely_ due to dir not empty), to ignoring some other errors from more protected dirs that are not empty. That adjustment was made to better support use with --parents, to essentially remove as much of a hierarchy as possible, without erroring as we hit more protected non empty parent dirs. That functionality adjustment was originally discussed at: https://lists.gnu.org/r/bug-coreutils/2008-01/msg00283.html * src/rmdir.c (usage): Adjust to be more accurate to current behavior. Also adjust --parents option to be easier to read. * doc/coreutils.texi (rmdir invocation): Likewise. Reported at https://github.com/coreutils/coreutils/issues/40
2022-04-14build: copy: fix build on macos 10.12Pádraig Brady-0/+5
* src/copy.c (copy_reg): Handle the case where CLONE_NOOWNERCOPY is not defined. Reported by Jeffrey Walton
2022-04-13tail: detect closed stdout on SolarisPádraig Brady-4/+4
* src/tail.c (check_output_alive): Use poll() on Solaris. Also handle POLLHUP, which Solaris returns in this case. * tests/tail-2/pipe-f.sh: Use `head -n2` rather than `sed 2q` as Solaris sed does not exit in this case. * NEWS: Mention the improvement. Reported by Bruno Haible.
2022-04-12cp,mv,install: avoid excess stat calls on non-GNUPaul Eggert-9/+13
* gl/lib/targetdir.c (target_directory_operand): New arg ST. All callers changed. * src/cp.c (do_copy): * src/mv.c (main): Avoid unnecessary stat call if target_directory_operand already got the status.
2022-04-12cp,mv,install: modularize targetdirPaul Eggert-74/+3
Move target directory code out of system.h to a new targetdir module. This doesn’t change functionality. * bootstrap.conf (gnulib_modules): Add targetdir. * src/cp.c, src/install.c, src/mv.c: Include targetdir.h. * src/system.h (must_be_working_directory, target_directory_operand) (targetdir_dirfd_valid): Move from here ... * gl/lib/targetdir.c, gl/lib/targetdir.h, gl/modules/targetdir: ... to these new files.