--- a/Win32OS.st Tue May 18 21:08:55 1999 +0200
+++ b/Win32OS.st Wed May 19 10:49:18 1999 +0200
@@ -2375,32 +2375,51 @@
"/ ...this will change in an upcoming version to include
"/ command.com command-line parsing here (sigh).
+self isMSWINDOWSNTlike ifTrue:[
+ 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 := false.
(aCommandString isNil or:[aCommandString includesAny:'<>|']) ifTrue:[
- hasRedirection := true
+ hasRedirection := true
] ifFalse:[
- words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space.
- args := ' '.
- words from:2 to:(words size) do:[:s |
- args := args , (s , ' ').
- ].
+ words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space.
+ args := ' '.
+ words from:2 to:(words size) do:[:s |
+ args := args , (s , ' ').
+ ].
].
"/ I/O redirection is not yet handled directly
"/ fallBack to command.com (below) to do it.
hasRedirection ifFalse:[
- 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
- ].
+ 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
+ ].
].
"/ windows-NT (where command.com works)
@@ -2408,23 +2427,23 @@
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.1.1998 / 16:57:19 / md"
- "Modified: / 15.5.1999 / 18:03:39 / cg"
+ "Modified: / 19.5.1999 / 10:01:24 / cg"
!
exec:aCommandPath withArguments:argString fileDescriptors:fdArray closeDescriptors:closeFdArray fork:doFork newPgrp:newPgrp inDirectory:aDirectory
@@ -2588,7 +2607,8 @@
if (__isString(dirName)) {
dir = __stringVal(dirName);
}
- if (__isString(commandPath) && __isString(commandLine)) {
+ if ((__isString(commandPath) || (commandPath == nil))
+ && __isString(commandLine)) {
#if 0
/*
* generate command line (cmd plus args)
@@ -2632,8 +2652,10 @@
}
}
#endif
+ if (commandPath != nil) {
+ cmdPath = __stringVal(commandPath);
+ }
cmdLine = __stringVal(commandLine);
- cmdPath = __stringVal(commandPath);
/*
* create descriptors as req'd
@@ -2759,30 +2781,50 @@
Use #monitorPid:action: for synchronization and exec status return,
or #killProcess: to stop it."
- |in out err shellAndArgs|
+ |ret in out err shellAndArgs errStream outStream inStream|
anExternalInStream notNil ifTrue:[
- in := anExternalInStream fileDescriptor.
+ in := anExternalInStream fileDescriptor.
+ ] ifFalse:[
+ inStream := 'nul' asFilename readStream.
+ in := inStream fileDescriptor.
].
anExternalOutStream notNil ifTrue:[
- out := anExternalOutStream fileDescriptor.
+ out := anExternalOutStream fileDescriptor.
+ ] ifFalse:[
+ outStream := 'nul' asFilename writeStream.
+ out := outStream fileDescriptor.
].
anExternalErrStream notNil ifTrue:[
- err := anExternalErrStream fileDescriptor.
+ err := anExternalErrStream fileDescriptor.
+ ] ifFalse:[
+ errStream := 'nul' asFilename writeStream.
+ err := errStream fileDescriptor.
].
shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
- ^ self
- exec:(shellAndArgs at:1)
- withArguments:(shellAndArgs at:2)
- fileDescriptors:(Array with:in with:out with:err)
- closeDescriptors:nil
- fork:true
- newPgrp:false
- inDirectory:dirOrNil
-
- "Modified: / 10.11.1998 / 20:43:12 / cg"
+ ret := self
+ exec:(shellAndArgs at:1)
+ withArguments:(shellAndArgs at:2)
+ fileDescriptors:(Array with:in with:out with:err)
+ closeDescriptors:nil
+ fork:true
+ newPgrp:false
+ inDirectory:dirOrNil.
+
+ inStream notNil ifTrue:[
+ inStream close
+ ].
+ outStream notNil ifTrue:[
+ outStream close
+ ].
+ errStream notNil ifTrue:[
+ errStream close
+ ].
+ ^ ret
+
"Created: / 10.11.1998 / 20:48:35 / cg"
+ "Modified: / 19.5.1999 / 10:43:01 / cg"
! !
!Win32OperatingSystem class methodsFor:'file access'!
@@ -4275,7 +4317,7 @@
See ExternalStream>>makePipe for a more user-friendly, public interface."
|fd1 fd2|
-
+
%{
HANDLE pipeRead = (HANDLE)0;
HANDLE pipeWrite = (HANDLE)0;
@@ -6615,6 +6657,6 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/Win32OS.st,v 1.48 1999-05-16 10:41:07 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/Win32OS.st,v 1.49 1999-05-19 08:49:18 cg Exp $'
! !
Win32OperatingSystem initialize!
--- a/Win32OperatingSystem.st Tue May 18 21:08:55 1999 +0200
+++ b/Win32OperatingSystem.st Wed May 19 10:49:18 1999 +0200
@@ -2375,32 +2375,51 @@
"/ ...this will change in an upcoming version to include
"/ command.com command-line parsing here (sigh).
+self isMSWINDOWSNTlike ifTrue:[
+ 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 := false.
(aCommandString isNil or:[aCommandString includesAny:'<>|']) ifTrue:[
- hasRedirection := true
+ hasRedirection := true
] ifFalse:[
- words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space.
- args := ' '.
- words from:2 to:(words size) do:[:s |
- args := args , (s , ' ').
- ].
+ words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space.
+ args := ' '.
+ words from:2 to:(words size) do:[:s |
+ args := args , (s , ' ').
+ ].
].
"/ I/O redirection is not yet handled directly
"/ fallBack to command.com (below) to do it.
hasRedirection ifFalse:[
- 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
- ].
+ 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
+ ].
].
"/ windows-NT (where command.com works)
@@ -2408,23 +2427,23 @@
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.1.1998 / 16:57:19 / md"
- "Modified: / 15.5.1999 / 18:03:39 / cg"
+ "Modified: / 19.5.1999 / 10:01:24 / cg"
!
exec:aCommandPath withArguments:argString fileDescriptors:fdArray closeDescriptors:closeFdArray fork:doFork newPgrp:newPgrp inDirectory:aDirectory
@@ -2588,7 +2607,8 @@
if (__isString(dirName)) {
dir = __stringVal(dirName);
}
- if (__isString(commandPath) && __isString(commandLine)) {
+ if ((__isString(commandPath) || (commandPath == nil))
+ && __isString(commandLine)) {
#if 0
/*
* generate command line (cmd plus args)
@@ -2632,8 +2652,10 @@
}
}
#endif
+ if (commandPath != nil) {
+ cmdPath = __stringVal(commandPath);
+ }
cmdLine = __stringVal(commandLine);
- cmdPath = __stringVal(commandPath);
/*
* create descriptors as req'd
@@ -2759,30 +2781,50 @@
Use #monitorPid:action: for synchronization and exec status return,
or #killProcess: to stop it."
- |in out err shellAndArgs|
+ |ret in out err shellAndArgs errStream outStream inStream|
anExternalInStream notNil ifTrue:[
- in := anExternalInStream fileDescriptor.
+ in := anExternalInStream fileDescriptor.
+ ] ifFalse:[
+ inStream := 'nul' asFilename readStream.
+ in := inStream fileDescriptor.
].
anExternalOutStream notNil ifTrue:[
- out := anExternalOutStream fileDescriptor.
+ out := anExternalOutStream fileDescriptor.
+ ] ifFalse:[
+ outStream := 'nul' asFilename writeStream.
+ out := outStream fileDescriptor.
].
anExternalErrStream notNil ifTrue:[
- err := anExternalErrStream fileDescriptor.
+ err := anExternalErrStream fileDescriptor.
+ ] ifFalse:[
+ errStream := 'nul' asFilename writeStream.
+ err := errStream fileDescriptor.
].
shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
- ^ self
- exec:(shellAndArgs at:1)
- withArguments:(shellAndArgs at:2)
- fileDescriptors:(Array with:in with:out with:err)
- closeDescriptors:nil
- fork:true
- newPgrp:false
- inDirectory:dirOrNil
-
- "Modified: / 10.11.1998 / 20:43:12 / cg"
+ ret := self
+ exec:(shellAndArgs at:1)
+ withArguments:(shellAndArgs at:2)
+ fileDescriptors:(Array with:in with:out with:err)
+ closeDescriptors:nil
+ fork:true
+ newPgrp:false
+ inDirectory:dirOrNil.
+
+ inStream notNil ifTrue:[
+ inStream close
+ ].
+ outStream notNil ifTrue:[
+ outStream close
+ ].
+ errStream notNil ifTrue:[
+ errStream close
+ ].
+ ^ ret
+
"Created: / 10.11.1998 / 20:48:35 / cg"
+ "Modified: / 19.5.1999 / 10:43:01 / cg"
! !
!Win32OperatingSystem class methodsFor:'file access'!
@@ -4275,7 +4317,7 @@
See ExternalStream>>makePipe for a more user-friendly, public interface."
|fd1 fd2|
-
+
%{
HANDLE pipeRead = (HANDLE)0;
HANDLE pipeWrite = (HANDLE)0;
@@ -6615,6 +6657,6 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.48 1999-05-16 10:41:07 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.49 1999-05-19 08:49:18 cg Exp $'
! !
Win32OperatingSystem initialize!