From: Francesco Noferi lolisamurai@tfwno.gf
Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=48396
Signed-off-by: Francesco Noferi lolisamurai@tfwno.gf Signed-off-by: Myah Caron qsniyg@protonmail.com --- The idea is based on Francesco's patch, but the implementation and comments have mostly been copied from WCMD_copy.
programs/cmd/builtins.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 70ccddebc11..3e6ecada6a8 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -3032,15 +3032,28 @@ void WCMD_move (void) WCHAR copycmd[MAXSTRING]; DWORD len;
- /* /-Y has the highest priority, then /Y and finally the COPYCMD env. variable */ + /* Default whether automatic overwriting is on. If we are interactive then + we prompt by default, otherwise we overwrite by default + /-Y has the highest priority, then /Y and finally the COPYCMD env. variable */ if (wcsstr (quals, parmNoY)) force = FALSE; else if (wcsstr (quals, parmY)) force = TRUE; else { static const WCHAR copyCmdW[] = {'C','O','P','Y','C','M','D','\0'}; + /* By default, we will force the overwrite in batch mode and ask for + * confirmation in interactive mode. */ + force = !interactive; + /* If COPYCMD is set, then we force the overwrite with /Y and ask for + * confirmation with /-Y. If COPYCMD is neither of those, then we use the + * default behavior. */ len = GetEnvironmentVariableW(copyCmdW, copycmd, ARRAY_SIZE(copycmd)); - force = (len && len < ARRAY_SIZE(copycmd) && !lstrcmpiW(copycmd, parmY)); + if (len && len < ARRAY_SIZE(copycmd)) { + if (!lstrcmpiW (copycmd, parmY)) + force = TRUE; + else if (!lstrcmpiW (copycmd, parmNoY)) + force = FALSE; + } }
/* Prompt if overwriting */ @@ -3051,14 +3064,16 @@ void WCMD_move (void) question = WCMD_format_string(WCMD_LoadMessage(WCMD_OVERWRITE), dest); ok = WCMD_ask_confirm(question, FALSE, NULL); LocalFree(question); + } else { + ok = TRUE; + }
- /* So delete the destination prior to the move */ - if (ok) { - if (!DeleteFileW(dest)) { - WCMD_print_error (); - errorlevel = 1; - ok = FALSE; - } + /* So delete the destination prior to the move */ + if (ok) { + if (!DeleteFileW(dest)) { + WCMD_print_error (); + errorlevel = 1; + ok = FALSE; } } } -- 2.28.0
This patch should fix https://bugs.winehq.org/show_bug.cgi?id=48397 as well, due to the `if (ok)` block being moved out of `if (!force)`
Should I split this up into two patches instead then, one for each bug? Or does this one patch suffice?
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=78492
Your paranoid android.
=== debiant (32 bit report) ===
cmd.exe: batch.c:321: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 1346 (got 'file move with overwrite succeeded', wanted 'file move with overwrite succeeded@or_broken@file overwrite impossible!') batch.c:321: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 1347 (got 'bar', wanted 'bar@or_broken@baz') batch.c:321: Test failed: unexpected char 0x73 position 24 in line 1350 (got 'moving a file to itself should be a no-op!', wanted 'moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op!') batch.c:321: Test failed: unexpected char 0x31 position 12 in line 1351 (got 'ErrorLevel: 1', wanted 'ErrorLevel: 0@or_broken@ErrorLevel: 1')
=== debiant (32 bit Chinese:China report) ===
cmd.exe: batch.c:321: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 1346 (got 'file move with overwrite succeeded', wanted 'file move with overwrite succeeded@or_broken@file overwrite impossible!') batch.c:321: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 1347 (got 'bar', wanted 'bar@or_broken@baz') batch.c:321: Test failed: unexpected char 0x73 position 24 in line 1350 (got 'moving a file to itself should be a no-op!', wanted 'moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op!') batch.c:321: Test failed: unexpected char 0x31 position 12 in line 1351 (got 'ErrorLevel: 1', wanted 'ErrorLevel: 0@or_broken@ErrorLevel: 1')
=== debiant (32 bit WoW report) ===
cmd.exe: batch.c:321: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 1346 (got 'file move with overwrite succeeded', wanted 'file move with overwrite succeeded@or_broken@file overwrite impossible!') batch.c:321: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 1347 (got 'bar', wanted 'bar@or_broken@baz') batch.c:321: Test failed: unexpected char 0x73 position 24 in line 1350 (got 'moving a file to itself should be a no-op!', wanted 'moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op!') batch.c:321: Test failed: unexpected char 0x31 position 12 in line 1351 (got 'ErrorLevel: 1', wanted 'ErrorLevel: 0@or_broken@ErrorLevel: 1')
=== debiant (64 bit WoW report) ===
cmd.exe: batch.c:321: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 1346 (got 'file move with overwrite succeeded', wanted 'file move with overwrite succeeded@or_broken@file overwrite impossible!') batch.c:321: Test succeeded inside todo block: unexpected char 0x0 position -1 in line 1347 (got 'bar', wanted 'bar@or_broken@baz') batch.c:321: Test failed: unexpected char 0x73 position 24 in line 1350 (got 'moving a file to itself should be a no-op!', wanted 'moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op!') batch.c:321: Test failed: unexpected char 0x31 position 12 in line 1351 (got 'ErrorLevel: 1', wanted 'ErrorLevel: 0@or_broken@ErrorLevel: 1')