--- Begin Message ---
Subject: |
cp/mv: want a fatal --no-clobber |
Date: |
Fri, 27 Jan 2023 15:52:09 -0500 |
i've been under the mistaken assumption that the -n/--no-clobber option exits
non-zero when the target exists, but someone pointed out to me recently that
it silently ignores existing files. can we get a setting to control this ?
basically i've been writing things like:
if ! cp -n foo bar; then
... error out because bar already exists, or otherwise failed ...
fi
when really i need to write:
if [ -e bar ] || ! cp foo bar; then
... error out ...
fi
-mike
signature.asc
Description: PGP signature
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#61105: cp/mv: want a fatal --no-clobber |
Date: |
Tue, 31 Jan 2023 08:55:48 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 |
On 2023-01-30 13:35, Pádraig Brady wrote:
This is a good observation.
Also the current "skip" functionality of coreutils cp -n
is already catered for with the --update option.
For consistency, there too the exit status should reflect whether the cp
action was done.
I installed the attached patch to implement this; comments welcome. In
the meantime I'm boldly closing the bug report.
0001-cp-ln-mv-when-skipping-exit-with-nonzero-status.patch
Description: Text Data
--- End Message ---