From eb0db70967a45ab14d657b380b31d91e43a3e1f9 Mon Sep 17 00:00:00 2001 From: dirk Date: Thu, 12 Feb 2015 22:17:21 +0000 Subject: [PATCH] Fixed command line execution in Windows for delegates that move files --- MagickCore/delegate.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/MagickCore/delegate.c b/MagickCore/delegate.c index 17e687387..6201d9890 100644 --- a/MagickCore/delegate.c +++ b/MagickCore/delegate.c @@ -446,6 +446,27 @@ MagickExport int ExternalDelegateCommand(const MagickBooleanType asynchronous, } #endif #elif defined(MAGICKCORE_WINDOWS_SUPPORT) + { + register char + *p; + + /* + If a command shell is executed we need to change the forward slashes in + files to a backslash. We need to do this to keep Windows happy when we + want to 'move' a file. + + TODO: This won't work if one of the delegate parameters has a forward + slash as aparameter. + */ + p=strstr(sanitize_command, "cmd.exe /c"); + if (p != (char*) NULL) + { + p+=10; + for (; *p != '\0'; p++) + if (*p == '/') + *p=*DirectorySeparator; + } + } status=NTSystemCommand(sanitize_command,message); #elif defined(macintosh) status=MACSystemCommand(sanitize_command); @@ -458,10 +479,10 @@ MagickExport int ExternalDelegateCommand(const MagickBooleanType asynchronous, { if ((message != (char *) NULL) && (*message != '\0')) (void) ThrowMagickException(exception,GetMagickModule(),DelegateError, - "FailedToExecuteCommand","`%s' (%s)",command,message); + "FailedToExecuteCommand","`%s' (%s)",sanitize_command,message); else (void) ThrowMagickException(exception,GetMagickModule(),DelegateError, - "FailedToExecuteCommand","`%s' (%d)",command,status); + "FailedToExecuteCommand","`%s' (%d)",sanitize_command,status); } sanitize_command=DestroyString(sanitize_command); for (i=0; i < (ssize_t) number_arguments; i++) -- 2.40.0