`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>
A DETACHED_PROCESS child has no console, so leaving stderr on inherit()
dropped its output. Point it at the child's stdout the way replace_fds()
does with dup2_stderr(stdout()) on Unix: at nohup.out when stdout is a
terminal, at the existing redirection otherwise.
find_stdout() appends to nohup.out and reports it on stderr, so it is
called once and the handle is cloned for stderr rather than reopened.
Instead of scattering #[cfg(unix)] / #[cfg(windows)] through nohup.rs,
keep the platform-specific code in its own file behind a small shared
interface: prepare(), run() and set_output_file_mode().
The unix-only CannotDetach/CannotReplace variants move to a unix
PlatformError, so NohupError in nohup.rs is now platform independent.