#DOCUMENTATION by Micha
authorMichael Beyl <mb@exept.de>
Thu, 14 Jun 2018 13:17:14 +0200
changeset 23070 d45cd560ea79
parent 23069 27007bdd5c17
child 23109 c8ec00051542
#DOCUMENTATION by Micha class: Win32OperatingSystem class changed: #commandAndArgsForOSCommand:
Win32OperatingSystem.st
--- a/Win32OperatingSystem.st	Thu Jun 14 12:25:33 2018 +0200
+++ b/Win32OperatingSystem.st	Thu Jun 14 13:17:14 2018 +0200
@@ -3650,11 +3650,11 @@
      and whether a window should be opened (true, false or nil = let the executed program determine)
      as third element."
 
-    |shell args wDir cmdName path|
+    |shell args wDir cmdName path commandString|
 
     aCommandString isNonByteCollection ifTrue:[
-	"easy: the caller does not want a shell to be executed"
-	^ Array with:aCommandString first with:(aCommandString asStringWith:' ') with:nil.
+        "easy: the caller does not want a shell to be executed"
+        ^ Array with:aCommandString first with:(aCommandString asStringWith:' ') with:nil.
     ].
 
     "/
@@ -3680,60 +3680,66 @@
     cmdName := (aCommandString ? '') withoutSeparators.
 
     (cmdName isEmpty or:[cmdName includesAny:'<>|&']) ifFalse:[
-	"/ test whether the command is a plain executable;
-	"/ if so, no shell is required
-	|index file suffix|
-
-	cmdName first = $" ifTrue:[
-	    index := cmdName indexOf:$" startingAt:2.
-	] ifFalse:[
-	    index := 1.
-	].
-	index := cmdName indexOfSeparatorStartingAt:index.
-	index ~~ 0 ifTrue:[
-	    cmdName := cmdName copyFrom:1 to:(index-1).
-	    args := cmdName copyFrom:(index+1).
-	] ifFalse:[
-	    args := ''.
-	].
-
-	(cmdName first = $" and:[cmdName last = $"]) ifTrue:[
-	    cmdName := (cmdName copyFrom:2 to:cmdName size - 1) withoutSeparators.
-	].
-	file := cmdName asFilename.
-	file suffix isEmpty ifTrue:[
-	    file := file withSuffix:'exe'.
-	].
-	path := file fullAlternativePathName.
-	(OperatingSystem getBinaryType:path) notNil ifTrue:[
-	    "/ is an executable, no shell required
-	    ^ Array with:path with:aCommandString with:nil.
+        "/ test whether the command is a plain executable;
+        "/ if so, no shell is required
+        |index file suffix|
+
+        cmdName first = $" ifTrue:[
+            index := cmdName indexOf:$" startingAt:2.
+        ] ifFalse:[
+            index := 1.
+        ].
+        index := cmdName indexOfSeparatorStartingAt:index.
+        index ~~ 0 ifTrue:[
+            cmdName := cmdName copyFrom:1 to:(index-1).
+            args := cmdName copyFrom:(index+1).
+        ] ifFalse:[
+            args := ''.
+        ].
+
+        (cmdName first = $" and:[cmdName last = $"]) ifTrue:[
+            cmdName := (cmdName copyFrom:2 to:cmdName size - 1) withoutSeparators.
+        ].
+        file := cmdName asFilename.
+        file suffix isEmpty ifTrue:[
+            file := file withSuffix:'exe'.
+        ].
+        path := file fullAlternativePathName.
+        (OperatingSystem getBinaryType:path) notNil ifTrue:[
+            "/ is an executable, no shell required
+            ^ Array with:path with:aCommandString with:nil.
 "/                ^ Array with:path with:(path, ' ', args).
-	].
-	path := self pathOfCommand:cmdName.
-	(path notNil and:[(OperatingSystem getBinaryType:path) notNil]) ifTrue:[
-	    "/ is an executable, no shell required
-	    ^ Array with:path with:aCommandString with:nil.
+        ].
+        path := self pathOfCommand:cmdName.
+        (path notNil and:[(OperatingSystem getBinaryType:path) notNil]) ifTrue:[
+            "/ is an executable, no shell required
+            ^ Array with:path with:aCommandString with:nil.
 "/                ^ Array with:path with:(path, ' ', args).
-	].
+        ].
     ].
 
     shell := self getEnvironment:'COMSPEC'.
     shell isNil ifTrue:[
-	wDir := self getWindowsSystemDirectory asFilename.
-	shell := #('cmd.exe' 'command.com') detect:[:eachCommand|
-			(wDir / eachCommand) isExecutableProgram
-		    ] ifNone:[
-			self error:'no cmd.exe available'.
-		    ].
-	shell := (wDir / shell) pathName.
+        wDir := self getWindowsSystemDirectory asFilename.
+        shell := #('cmd.exe' 'command.com') detect:[:eachCommand|
+                        (wDir / eachCommand) isExecutableProgram
+                    ] ifNone:[
+                        self error:'no cmd.exe available'.
+                    ].
+        shell := (wDir / shell) pathName.
     ].
 
     cmdName isEmpty ifTrue:[
-	^ Array with:shell with:'' with:nil.
-    ].
-
-    ^ Array with:shell with:(' /c "' , aCommandString, '"') with:false.
+        ^ Array with:shell with:'' with:nil.
+    ].
+
+    commandString := aCommandString.
+    "/ cg: this has to be verified!!
+"/    (aCommandString includes:$") ifTrue:[
+"/        commandString := aCommandString copyReplaceString:'"' withString:'""'.
+"/    ].
+
+    ^ Array with:shell with:(' /c "' , commandString, '"') with:false.
 
    "
      self commandAndArgsForOSCommand:''