Renaming the temp onto a destination that is already a link to the same
inode does nothing and returns success, so the temp name survived:
`ln -f a b` with b already hard-linked to a left a stray Cu* file.
Unlink the temp after the rename either way; on the normal path it is
already gone.
replace links atomically instead of unlinking first
Forced replacement was unlink(dst) then create. The gap lets another user
claim dst in a directory they can write to -- including a name the sticky
bit forbids them to remove -- so a privileged ln hands them a trusted name.
`ln -f A B` unlinked B before attempting the link, so a link that failed
for any reason other than the destination already existing (a missing
source, a directory source, a dangling symlink with -L) left B deleted.
Attempt the link first and remove an existing destination only after the
link reports EEXIST, matching GNU, so a failed link never destroys the
destination.
Fixes#14550
Signed-off-by: nagendramohan <nagendramohan1990@gmail.com>
The rest of the input only got its own split when something was left
after the patterns, or when every pattern was a line number with
--suppress-matched. GNU always ends with that split, so a suppressed
match on the last line or an offset reaching the end of the input left
one file short. A {*} regex is the exception: it has already consumed
the input by the time it stops matching.
Apply escape quoting and TTY control-character display in Config instead of patching quoting_style in the dir and vdir wrappers.
Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
When LS_COLORS sets a `no` style, ls emits a reset sequence before the
first listed line. Those bytes were written straight to the output
without advancing the //DIRED// line offset, so every reported pair was
short by the length of the reset and pointed inside the escape sequence
instead of at the name.
print_dired_output ignored the BufWriter it was given and used the print
macros, which panic on a write error, and its flush reported one as a
plain I/O error. Write the trailer through the BufWriter instead, so a
failure is reported as GNU does: "write error", exit 2.
https://github.com/uutils/coreutils/issues/14497