Win32OperatingSystem.st
changeset 10386 491685fba02e
parent 10373 92efacf8b050
child 10443 c0b0ede4ab59
--- a/Win32OperatingSystem.st	Mon Feb 12 09:46:31 2007 +0100
+++ b/Win32OperatingSystem.st	Mon Feb 12 09:48:49 2007 +0100
@@ -2952,7 +2952,7 @@
 commandAndArgsForOSCommand:aCommandString
     "get a shell and shell arguments for command execution"
 
-    |shell args wDir path words hasRedirection|
+    |shell args wDir cmdName path words hasRedirection|
 
     "/
     "/ 'x:\WINNT\System32\cmd /c <command>'
@@ -2976,101 +2976,103 @@
     "/ command.com command-line parsing here (sigh).
     hasRedirection := false.
     (aCommandString isNil or:[aCommandString includesAny:'<>|']) ifTrue:[
-	hasRedirection := true
+        hasRedirection := true
     ].
 
     self isMSWINDOWSNTlike ifTrue:[
-	hasRedirection ifFalse:[
-	    |size name|
-
-	    "/ test whether the commandString is an executable;
-	    "/ then, no shell is required
-	    name := aCommandString withoutSeparators.
-	    (name notEmpty and:[(name startsWith:$") not]) ifTrue:[
-		|index file suffix|
-
-		index := name indexOfSeparatorStartingAt:1.
-		index ~~ 0 ifTrue:[
-		    name := name copyFrom:1 to:(index -1).
-		].
-
-		file   := name asFilename.
-		suffix := file suffix.
-
-		suffix isEmptyOrNil ifTrue:[
-		    suffix := 'exe'.
-		    file := file withSuffix:suffix.
-		].
-
-		(file exists and:[suffix = 'exe']) ifTrue:[
-		    "/ is an executable, no shell required
-		    ^ Array with:nil with:aCommandString.
-		]
-	    ].
-	].
-	shell := self getEnvironment:'COMSPEC'.
-	shell isNil ifTrue:[
-	    wDir := self getWindowsSystemDirectory asFilename.
-	    shell := (wDir construct:'cmd.exe').
-	    shell exists ifFalse:[
-		shell := (wDir construct:'command.com').
-		shell exists ifFalse:[
-		    self error:'no command.com available'.
-		]
-	    ].
-	    shell := shell pathName.
-	].
-	aCommandString isNil ifTrue:[
-	    ^ Array with:nil with:shell
-	].
-
-	^ Array with:nil with:(shell , ' /c ' , '"' , aCommandString , '"' )
+        hasRedirection ifFalse:[
+            "/ test whether the commandString is an executable;
+            "/ then, no shell is required
+            cmdName := aCommandString withoutSeparators.
+            (cmdName notEmpty and:[(cmdName startsWith:$") not]) ifTrue:[
+                |index file suffix|
+
+                index := cmdName indexOfSeparatorStartingAt:1.
+                index ~~ 0 ifTrue:[
+                    cmdName := cmdName copyFrom:1 to:(index -1).
+                ].
+
+                file   := cmdName asFilename.
+                suffix := file suffix.
+
+                suffix isEmptyOrNil ifTrue:[
+                    suffix := 'exe'.
+                    file := file withSuffix:suffix.
+                ].
+
+                (file exists and:[suffix = 'exe']) ifTrue:[
+                    "/ is an executable, no shell required
+                    ^ Array with:nil with:aCommandString.
+                ].
+                (self pathOfCommand:cmdName) notNil ifTrue:[
+                    "/ is an executable, no shell required
+                    ^ Array with:nil with:aCommandString.
+                ].
+            ].
+        ].
+        shell := self getEnvironment:'COMSPEC'.
+        shell isNil ifTrue:[
+            wDir := self getWindowsSystemDirectory asFilename.
+            shell := (wDir construct:'cmd.exe').
+            shell exists ifFalse:[
+                shell := (wDir construct:'command.com').
+                shell exists ifFalse:[
+                    self error:'no command.com available'.
+                ]
+            ].
+            shell := shell pathName.
+        ].
+        aCommandString isNil ifTrue:[
+            ^ Array with:nil with:shell
+        ].
+
+        ^ Array with:nil with:(shell , ' /c ' , '"' , aCommandString , '"' )
     ].
 
     "/ I/O redirection is not yet handled directly
     "/ fallBack to command.com (below) to do it.
 
     hasRedirection ifFalse:[
-	words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space.
-	args := ' '.
-	words from:2 to:(words size) do:[:s |
-	    args := args , (s , ' ').
-	].
-
-	path := self pathOfCommand:(words at:1).
-	path notNil ifTrue:[
-	    "/ execute the command directly -
-	    "/ without going through command.com
-
-	    self isMSWINDOWSNTlike ifTrue:[
-		args := path , args.
-	    ].
-
-	    ^ Array with:path with:args
-	].
+        words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space.
+        args := ' '.
+        words from:2 to:(words size) do:[:s |
+            args := args , (s , ' ').
+        ].
+
+        path := self pathOfCommand:(words at:1).
+        path notNil ifTrue:[
+            "/ execute the command directly -
+            "/ without going through command.com
+
+            self isMSWINDOWSNTlike ifTrue:[
+                args := path , args.
+            ].
+
+            ^ Array with:path with:args
+        ].
     ].
 
     "/ I/O redirection or no executable was found
 
     shell := self getEnvironment:'COMSPEC'.
     shell isNil ifTrue:[
-	wDir := self getWindowsSystemDirectory asFilename.
-	shell := (wDir construct:'cmd.exe').
-	shell exists ifFalse:[
-	    shell := (wDir construct:'command.com').
-	    shell exists ifFalse:[
-		self error:'no command.com available'.
-	    ]
-	].
-	shell := shell pathName.
+        wDir := self getWindowsSystemDirectory asFilename.
+        shell := (wDir construct:'cmd.exe').
+        shell exists ifFalse:[
+            shell := (wDir construct:'command.com').
+            shell exists ifFalse:[
+                self error:'no command.com available'.
+            ]
+        ].
+        shell := shell pathName.
     ].
     aCommandString isNil ifTrue:[
-	^ Array with:shell with:shell
+        ^ Array with:shell with:shell
     ].
     ^ Array with:shell with:(shell , ' /c ' , aCommandString)
 
     "Modified: / 20-01-1998 / 16:57:19 / md"
-    "Modified: / 12-05-2004 / 12:47:06 / cg"
+    "Modified: / 11-02-2007 / 20:51:08 / cg"
 !
 
 exec:aCommandPath withArguments:argString environment:environment fileDescriptors:fdArray fork:doFork newPgrp:newPgrp inDirectory:aDirectory
@@ -3467,36 +3469,36 @@
     aCommandString isNil ifTrue:[^ nil].
 
     (in := anExternalInStream) isNil ifTrue:[
-	nullStream := Filename nullDevice readWriteStream.
-	in := nullStream.
+        nullStream := Filename nullDevice readWriteStream.
+        in := nullStream.
     ].
     (out := anExternalOutStream) isNil ifTrue:[
-	nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
-	out := nullStream.
+        nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
+        out := nullStream.
     ].
     (err := anExternalErrStream) isNil ifTrue:[
-	err := out
+        err := out
     ].
     anAuxiliaryStream notNil ifTrue:[
-	auxFd := anAuxiliaryStream fileDescriptor
+        auxFd := anAuxiliaryStream fileDescriptor
     ].
 
     shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
 
     rslt := self
-	exec:(shellAndArgs at:1)
-	withArguments:(shellAndArgs at:2)
-	environment:anEvironmentDictionary
-	fileDescriptors:(Array with:in fileDescriptor
-			       with:out fileDescriptor
-			       with:err fileDescriptor
-			       with:auxFd)
-	fork:true
-	newPgrp:true "/ false
-	inDirectory:dir.
+        exec:(shellAndArgs at:1)
+        withArguments:(shellAndArgs at:2)
+        environment:anEvironmentDictionary
+        fileDescriptors:(Array with:in fileDescriptor
+                               with:out fileDescriptor
+                               with:err fileDescriptor
+                               with:auxFd)
+        fork:true
+        newPgrp:true "/ false
+        inDirectory:dir.
 
     nullStream notNil ifTrue:[
-	nullStream close.
+        nullStream close.
     ].
     ^ rslt
 
@@ -3519,7 +3521,7 @@
      The following will no longer work. monitorPid has disappeared
 
      pid notNil ifTrue:[
-	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
+         Processor monitorPid:pid action:[:OSstatus | sema signal ].
      ].
      in close.
      out close.
@@ -3531,7 +3533,7 @@
     "Modified: / 21-03-1997 / 10:04:35 / dq"
     "Modified: / 15-07-1997 / 16:03:51 / stefan"
     "Created: / 12-11-1998 / 14:39:20 / cg"
-    "Modified: / 12-05-2004 / 12:30:21 / cg"
+    "Modified: / 11-02-2007 / 20:13:28 / cg"
 ! !
 
 !Win32OperatingSystem class methodsFor:'file access'!
@@ -12758,7 +12760,7 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.265 2007-02-07 09:50:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.266 2007-02-12 08:48:49 cg Exp $'
 ! !
 
 Win32OperatingSystem initialize!