Myah Caron : cmd.exe: Don't prompt for move when non-interactive.

Alexandre Julliard julliard at winehq.org
Tue Mar 23 15:07:41 CDT 2021


Module: wine
Branch: oldstable
Commit: 088aa52d1f26af873aeb98619b6f5e4db6928bfd
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=088aa52d1f26af873aeb98619b6f5e4db6928bfd

Author: Myah Caron <qsniyg at protonmail.com>
Date:   Thu Sep 10 19:17:36 2020 +0000

cmd.exe: Don't prompt for move when non-interactive.

Based on a patch by Francesco Noferi.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48396
Signed-off-by: Myah Caron <qsniyg at protonmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit d1790c984bebb55e4d08644e84cfabd85abeefe2)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 programs/cmd/builtins.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 291b76dae90..418844a3d0c 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -3033,15 +3033,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 */




More information about the wine-cvs mailing list