GNU bug report logs - #70887
In coreutils 9.5, "cp" command does not honor "--interactive" option

Previous Next

Package: coreutils;

Reported by: Robert Hill <hill-robert <at> hotmail.com>

Date: Sun, 12 May 2024 01:03:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Robert Hill <hill-robert <at> hotmail.com>
Subject: bug#70887: closed (Re: bug#70887: In coreutils 9.5, "cp" command
 does not honor "--interactive" option)
Date: Mon, 06 Jan 2025 16:05:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#70887: In coreutils 9.5, "cp" command does not honor "--interactive" option

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 70887 <at> debbugs.gnu.org.

-- 
70887: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70887
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>, Robert Hill <hill-robert <at> hotmail.com>,
 70887-done <at> debbugs.gnu.org
Subject: Re: bug#70887: In coreutils 9.5, "cp" command does not honor
 "--interactive" option
Date: Mon, 6 Jan 2025 16:04:25 +0000
[Message part 3 (text/plain, inline)]
On 12/05/2024 21:31, Pádraig Brady wrote:
> On 12/05/2024 16:06, Paul Eggert wrote:
>> On 2024-05-12 04:49, Pádraig Brady wrote:
>>
>>> @@ -1151,7 +1151,8 @@ main (int argc, char **argv)
>>>                    {
>>>                      /* Default cp operation.  */
>>>                      x.update = false;
>>> -                  x.interactive = I_UNSPECIFIED;
>>> +                  if (x.interactive != I_ASK_USER)
>>> +                    x.interactive = I_UNSPECIFIED;
>>>                    }
>>>                  else if (update_opt == UPDATE_NONE)
>>>                    {
>>> @@ -1166,7 +1167,8 @@ main (int argc, char **argv)
>>>                  else if (update_opt == UPDATE_OLDER)
>>>                    {
>>>                      x.update = true;
>>> -                  x.interactive = I_UNSPECIFIED;
>>> +                  if (x.interactive != I_ASK_USER)
>>> +                    x.interactive = I_UNSPECIFIED;
>>
>> Thanks for looking into this messy area. Here is a comment from another
>> pair of eyes.
>>
>> Could you elaborate a bit more about why these two bits of code change
>> x.interactive at all? That is, why doesn't update_opt simply affect
>> x.update? Why does update_opt bother to override a previous setting of
>> x.interactive to I_ALWAYS_YES, I_ALWAYS_NO, or I_ALWAYS_SKIP?
>>
>> Another way to put it: shouldn't x.update simply reflect the value of
>> the --update option, whereas x.interactive reflects reflects whether -f,
>> -i, -n are used? Although this would require changes to copy.c, it'd
>> make the code easier to follow.
> 
> I agree that some refactoring would be good here.
> At least x.update should be renamed to x.update_older.
> 
> As interactive selection, and file dates all relate
> to selecting which files to update, it's tempting to conflate the settings.
> However you're right that this introduces complexities when
> trying to avoid all inconsistencies. Currently for example:
>     $ cp -v -i --update=none new old  # Won't prompt as expected
>     $ cp -v --update=none -i new old  # Unexpectedly ignores update option
> 
> So yes we should separate these things.
> 
>> Another way to put it: why should, for example, --update=all override a
>> previous -f or (partly) -n but not a previous -i?
> 
> Right -f is significant for mv here (for completeness -f for cp is a separate thing).
> I.e. we need to treat I_ALWAYS_YES specially in mv with the current scheme.
> 
> BTW -n is not overridden by any --update option currently,
> and this change effectively applies the same logic to -i now.

The attached patch set should address this.
Marking this as done.
I'll push the attached tomorrow.

cheers,
Pádraig
[0001-doc-clarify-mv-f-operation-in-texinfo.patch (text/x-patch, attachment)]
[0002-cp-mv-ensure-i-f-are-not-overridden-by-u.patch (text/x-patch, attachment)]
[0003-cp-mv-uncouple-update-and-f-i-n-options.patch (text/x-patch, attachment)]
[Message part 7 (message/rfc822, inline)]
From: Robert Hill <hill-robert <at> hotmail.com>
To: "bug-coreutils <at> gnu.org" <bug-coreutils <at> gnu.org>
Subject: In coreutils 9.5, "cp" command does not honor "--interactive" option
Date: Sat, 11 May 2024 23:03:09 +0000
[Message part 8 (text/plain, inline)]
After upgrading coreutils from 9.0 to 9.5, the following change occurred:

In coreutils 9.0, the command "cp -Tipruvx /src-dir /dst-dir" requested
interactive confirmation before replacing an old destination file with a
newer source file, as expected.

In coreutils 9.5, the command "cp -Tipruvx /src-dir /dst-dir" no longer
requests interactive confirmation, but just goes ahead and replaces old
destination files with newer source files, which is not expected.

Thank you in advance for looking at this, Bob.

[Message part 9 (text/html, inline)]

This bug report was last modified 213 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.