summaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorLines
2022-04-13cp,mv,install: avoid EACCES with non directory destinationPádraig Brady-7/+11
* src/system.h (target_directory_operand): Also check with stat() on systems with O_SEARCH, to avoid open("file", O_SEARCH|O_DIRECTORY) returning EACCES rather than ENOTDIR, which was seen on Solaris 11.4 when operating on non dirs without execute bit set. * NEWS: Remove related bug entry, as that issue was only introduced after coreutils v9.0 was released. Reported by Bruno Haible.
2022-04-13sync: support syncing files on cygwinPádraig Brady-2/+2
* src/sync.c (sync_arg): Similarly to AIX, Cygwin 2.9.0 was seen to need write access to have permission to sync a file.
2022-04-09cp,mv,install: avoid opening non directory destinationPádraig Brady-4/+17
commit v9.0-66-ge2daa8f79 introduced an issue, for example where cp could hang when overwriting a destination fifo, when it would try to open() the fifo on systems like Solaris 10 that didn't support the O_DIRECTORY flag. This is still racy on such systems, but only in the case where a directory is replaced by a fifo in the small window between stat() and open(). * src/system.h (target_directory_operand): On systems without O_DIRECTORY, ensure the file is a directory before attempting to open(). * tests/cp/special-f.sh: Protect cp with timeout(1), as cp was seen to hang when trying to overwrite an existing fifo. * NEWS: Mention the bug fix.
2022-04-09doc: install --compare: clarify mode of operationPádraig Brady-2/+3
* doc/coreutils.texi (install invocation): For the --compare option, clarify that the ownership or permissions of the source files don't matter. Also don't imply --owner or --group need to be specified for --compare to be effective. * src/install.c (usage): Add more detail on what's being compared. Fixes https://bugs.gnu.org/50889
2022-04-07build: update gnulib submodule to latestPádraig Brady-16/+21
* gnulib: Update to latest * src/copy.c: Replace deprecated {l,}statat(), with fstatat(). * src/cp.c: Likewise. * src/install.c: Likewise. * src/remove.c: Likewise.
2022-04-04factor: improve support on RISCV and loongsonPádraig Brady-2/+13
* src/longlong.h: Pull in RISCV fix and loongarch64 support from https://gmplib.org/repo/gmp/log/tip/longlong.h
2022-04-03ls: avoid expensive capability lookup by defaultPádraig Brady-2/+2
Lookup of file-based capabilities adds 30% overhead to the common case of ls --color usage. Since the use of file capabilities is very rare, it doesn't make sense to pay this cost in the common case. It's better to use getcap to inspect capabilities, and the following run shows only 8 files using capabilities on my fedora 35 distro (14 years after the feature was introduced to the linux kernel). $ getcap -r / /usr/bin/arping = cap_net_raw+p /usr/bin/clockdiff = cap_net_raw+p /usr/bin/gnome-keyring-daemon = cap_ipc_lock+ep /usr/bin/gnome-shell = cap_sys_nice+ep /usr/bin/newgidmap = cap_setgid+ep /usr/bin/newuidmap = cap_setuid+ep /usr/sbin/mtr-packet = cap_net_raw+ep /usr/sbin/suexec = cap_setgid,cap_setuid+ep * src/dircolors.hin: Set "CAPABILITY" to "00", to indicate unused. * src/ls.c: Set the default C_CAP color to not colored. * NEWS: Mention the change in behavior.
2022-04-03dircolors: colorize backup files with bright blackVille Skyttä-0/+19
* src/dircolors.hin: Add patterns for suffixes for "backup files". The color used is so they stand out less than non-backup files, and bright black works well on both light and dark backgrounds. * THANKS.in: Remove duplicate. Fixes https://bugs.gnu.org/54521
2022-03-29doc: join: clarify that -e only effective for -12jo fieldsPádraig Brady-1/+5
* src/join.c (usage): Clarify that -e is not sufficient to enable output of missing fields from one of the inputs. Rather the -12jo options are required to explicitly enable output of those fields. Fixes https://bugs.gnu.org/54625
2022-03-19printf: support printing the numeric value of multi-byte charsPádraig Brady-0/+16
* src/printf.c (STRTOX): Update to support multi-byte chars. * tests/misc/printf-mb.sh: Add a new test. * tests/local.mk: Reference the new test. * NEWS: Mention the improvement. Fixes https://bugs.gnu.org/54388
2022-03-12doc: test: clarify that -rwx don't just check perm bitsPádraig Brady-3/+3
* src/test.c (usage): State that -rwx is determined by user access, rather than permission bits. * doc/coreutils.texi (Access permission tests): Likewise. * man/test.x [SEE ALSO]: access(2). Fixes https://bugs.gnu.org/54338
2022-03-07maint: address syntax-check issues in recent commitPádraig Brady-1/+1
* cfg.mk (sc_die_EXIT_FAILURE): Generalize to match any EXIT_ define, and also relax to ignore error() usage with ternary operator. * src/chroot.c (main): Use () to avoid the sc_error_quotes check.
2022-03-07stat: only automount with --cached=neverPádraig Brady-0/+3
Revert to the default behavior before the introduction of statx(). * src/stat.c (do_stat): Set AT_NO_AUTOMOUNT without --cached=never. * doc/coreutils.texi (stat invocation): Mention the automount behavior with --cached=never. * NEWS: Mention the change in behavior. Fixes https://bugs.gnu.org/54287
2022-03-07ls: avoid triggering automountsRohan Sable-1/+1
statx() has different defaults wrt automounting compared to stat() or lstat(), so explicitly set the AT_NO_AUTOMOUNT flag to suppress that behavior, and avoid unintended operations or potential errors. * src/ls.c (do_statx): Pass AT_NO_AUTOMOUNT to avoid this behavior. * NEWS: Mention the change in behavior. Fixes https://bugs.gnu.org/54286 Signed-off-by: Rohan Sable <rsable@redhat.com>
2022-03-05date: fix newly-introduced %%-N bugPaul Eggert-5/+10
* src/date.c (adjust_resolution): Don’t mishandle %%-N. * tests/misc/date.pl (pct-pct): New test.
2022-02-24chown: warn about USER.GROUPPaul Eggert-11/+15
Suggested by Dan Jacobson (Bug#44770). * src/chown.c, src/chroot.c (main): Issue warnings if obsolete USER.GROUP notation is present.
2022-02-24fmt: fix invalid multi-byte splitting on macOSPádraig Brady-1/+2
On macOS, isspace(0x85) returns true, which results in splitting within multi-byte characters. * src/fmt.c (get_line): s/isspace/c_isspace/. * tests/fmt/non-space.sh: Add a new test. * tests/local.mk: Reference new test. * NEWS: Mention the fix. Addresses https://bugs.gnu.org/54124
2022-02-22dd: counts ending in "B" now count bytesPaul Eggert-58/+56
This implements my suggestion in Bug#54112. * src/dd.c (usage): Document the change. (parse_integer, scanargs): Implement the change. Omit some now-obsolete checks for invalid flags. * tests/dd/bytes.sh: Test the new behavior, while retaining checks for the now-obsolete usage. * tests/dd/nocache_eof.sh: Avoid now-obsolete usage.
2022-02-22dd: support iseek= and oseek=Paul Eggert-4/+4
Alias iseek=N to skip=N, oseek=N to seek=N (Bug#45648). * src/dd.c (scanargs): Parse iseek= and oseek=. * tests/dd/skip-seek.pl (sk-seek5): New test case.
2022-02-21cp: avoid unnecessary buffer allocationPaul Eggert-9/+12
Do not allocate I/O buffer if copy_file_range suffices. * src/copy.c (sparse_copy, lseek_copy): Buffer arg is now char ** instead of char *, and buffer is now allocated only if needed. All uses changed.
2022-02-15dircolors: speed up processing of TERM entriesPádraig Brady-8/+4
* src/dircolors.c (main): Avoid glob matching when we've already matched in a group of {COLOR,}TERM entries.
2022-02-15dircolors: consider COLORTERM as well as TERM env varsPádraig Brady-3/+22
COLORTERM is an environment used usually to expose truecolor support in terminal emulators. Therefore support matches on that in addition to TERM. Also set the default COLORTERM match pattern so that we apply colors if COLORTERM is any value. This implicitly supports a terminal like "foot" without a need for an explicit TERM entry. * NEWS: Mention the new feature. * src/dircolors.c (main): Match COLORTERM like we do for TERM. * src/dircolors.hin: Add default config to match any COLORTERM. * tests/misc/dircolors.pl: Add test cases.
2022-02-14tr: improve multibyte etc. docPaul Eggert-15/+15
Problem reported by Dan Jacobson (Bug#48248). * doc/coreutils.texi (tr invocation): Improve documentation for tr's failure to support multibyte characters POSIX-style. * doc/coreutils.texi (tr invocation), src/tr.c (usage): Use terminology closer to POSIX's.
2022-02-13dircolors: add --print-ls-colors to display colored entriesPádraig Brady-63/+86
* NEWS: Mention the new feature. * doc/coreutils.texi (dircolors invocation): Describe the new --print-ls-colors option. * src/dircolors.c (print_ls_colors): A new global to select between shell or terminal output. (append_entry): A new function refactored from dc_parse_stream() to append the entry in the appropriate format. (dc_parse_stream): Adjust to call append_entry(). * tests/misc/dircolors.pl: Add test cases.
2022-02-13chown,chgrp: reinstate numeric id output in -v messagesPádraig Brady-9/+35
since gnulib commit ff208d546a, related to coreutils commit v9.0-143-gabde15969 we no longer maintain numeric IDs through chopt->{user,group}_name. Therefore we need to adjust to ensure tests/chown/basic.sh passes. * src/chown-core.c (uid_to_str, gid_to_str): New helper functions to convert numeric id to string. (change_file_owner): Use the above new functions to pass numeric ids to describe_change().
2022-02-12sort: fix several version-sort problemsPaul Eggert-8/+10
This also affects ls -v in some corner cases. Problems reported by Michael Debertol <https://bugs.gnu.org/49239>. While looking into this, I spotted some more areas where the code and documentation did not agree, or where the documentation was unclear. In some cases I changed the code; in others the documentation. I hope things are nailed down better now. * doc/sort-version.texi: Distinguish more carefully between characters and bytes. Say that non-identical strings can compare equal, since they now can. Improve readability in various ways. Make it clearer that a suffix can be the entire string. * src/ls.c (cmp_version): Fall back on strcmp if filevercmp reports equality, since filevercmp is no longer a total order. * src/sort.c (keycompare): Use filenvercmp, to treat NULs correctly. * tests/misc/ls-misc.pl (v_files): Adjust test to match new behavior. * tests/misc/sort-version.sh: Add tests for stability, and for sorting with NUL bytes.
2022-02-12doc: avoid using "[" is URLS in --help outputPádraig Brady-1/+5
* src/system.h (emit_ancillary_info): While supported if entered manually, the "[" character is not highlighted as part of a URL by default in terminals, so avoid using it. Addresses https://bugs.gnu.org/53946
2022-02-12doc: adust --help, --version alignmentPádraig Brady-2/+2
* src/system.h: Adjust the alignment of the --help and --version option descriptions, to start at column 21. This better aligns with the descriptions of most commands, and also aligns with the minimum column a description must start at to ensure a blank line is not output when a description follows an option on a line by itself.
2022-02-12doc: rmdir: improve --help formattingPádraig Brady-4/+10
* src/rmdir.c (usage): Move description to column 21, so that a --long-option on its own line without a trailing description, doesn't have an erroneous blank line inserted between the option and description. Also group descriptions with blank lines rather than indents, so that man pages don't have erroneous blank lines added within the description. Addresses https://bugs.gnu.org/53946
2022-02-12doc: ls: reference dircolors(1) from --helpPádraig Brady-1/+1
* src/ls.c (usage): s/dircolors/dircolors(1)/. * man/ls.x [SEE ALSO]: Reference dircolors(1). Addresses https://bugs.gnu.org/53946
2022-02-12doc: ls: improve --help formattingPádraig Brady-23/+68
* src/ls.c (usage): Use blank lines to group multi-line option descriptions, rather than indenting. This results in more consistent alignment of descriptions, and also avoids erroneous new lines in generated in man pages. Addresses https://bugs.gnu.org/53946
2022-02-07dircolors: highlight .avif as imageChristian Hesse-0/+1
This add highlighting for AV1 Image File Format (AVIF): https://aomediacodec.github.io/av1-avif/ * src/dircolors.hin: Highlight .avif as image. Signed-off-by: Christian Hesse <mail@eworm.de>
2022-02-04date: improve docPaul Eggert-1/+2
Problem reported by Dan Jacobson (Bug#51288). * doc/coreutils.texi (date invocation, Setting the time) (Options for date): * src/date.c (usage): Improve doc.
2022-02-04id: print groups of listed namePaul Eggert-16/+14
Problem reported by Vladimir D. Seleznev (Bug#53631). * src/id.c (main): Do not canonicalize user name before deciding what groups the user belongs to.
2022-01-31tr: pacify -fsanitizer=leakPaul Eggert-2/+2
* src/tr.c (main): Use main_exit, not return, in a couple of places missed last time.
2022-01-31chgrp: fix typo in previous changePaul Eggert-1/+1
* src/chgrp.c (main): Use main_exit, not exit.
2022-01-31maint: mark some _Noreturn functionsPaul Eggert-6/+6
* src/basenc.c (finish_and_exit, do_encode, do_decode): * src/comm.c (compare_files): * src/tsort.c (tsort): * src/uptime.c (uptime): Mark with _Noreturn. Otherwise, unoptimized compilations may warn that the calling renamed-main function doesn't return a value, when !lint and when single-binary.
2022-01-31df: fix memory leakPaul Eggert-10/+4
* src/df.c (devlist_free): Remove. (filter_mount_list): Free all of devlist, instead of merely the entries in devlist_table.
2022-01-31maint: cut: avoid exporting recently added variablePádraig Brady-1/+1
* src/cut.c: Make output_delimiter_default static, as identified by `make syntax-check`.
2022-01-31dd: do not access uninitializedPaul Eggert-3/+5
* src/dd.c (parse_integer): Avoid undefined behavior that accesses an uninitialized ‘n’ when e == LONGINT_INVALID. Return more-accurate error code when INTMAX_MAX < n.
2022-01-31uptime: simplify -fsanitize=leak pacificationPaul Eggert-3/+1
* src/uptime.c (uptime): Exit here ... (main): ... instead of here.
2022-01-31uniq: remove IF_LINTPaul Eggert-1/+1
* src/uniq.c (check_file): Remove a no-longer-needed IF_LINT.
2022-01-31unexpand: remove IF_LINTPaul Eggert-1/+1
* src/unexpand.c (unexpand): Remove a no-longer-needed IF_LINT.
2022-01-31pr: remove IF_LINTPaul Eggert-1/+1
* src/pr.c (read_line): Remove a no-longer-needed IF_LINT.
2022-01-31truncate: simplifyPaul Eggert-14/+11
* src/truncate.c (do_ftruncate): Check != 0 instead of == -1. Avoid a cast. (main): Use C99 style decls after statements. Simplify ‘open’ logic.
2022-01-31shred: remove IF_LINTPaul Eggert-1/+1
* src/shred.c (dopass): Remove a no-longer-needed IF_LINT. (read_line): Remove an IF_LINT; no longer needed with today’s GCC.
2022-01-31pr: simplify -fsanitize=leak pacificationPaul Eggert-2/+1
* src/pr.c (main): Remove an IF_LINT. Use main_exit rather than return.
2022-01-31pinky: simplify -fsanitize=leak pacificationPaul Eggert-2/+1
* src/pinky.c (short_pinky): exit instead of freeing.
2022-01-31paste: remove IF_LINTPaul Eggert-2/+2
* src/paste.c (paste_parallel): Remove no-longer-needed IF_LINT.
2022-01-31hostname: simplifyPaul Eggert-22/+19
* src/hostname.c (sethostname): Provide a substitute on all platforms, to simplify the mainline code. (main): Simplify. Remove an IF_LINT. Use main_exit rather than return.