AbstractOperatingSystem.st
branchjv
changeset 20346 fd33c56536df
parent 20345 68e5382ae472
parent 20336 9b11122ce38b
child 20398 8cb53f870d39
--- a/AbstractOperatingSystem.st	Fri Sep 02 17:32:16 2016 +0100
+++ b/AbstractOperatingSystem.st	Sat Sep 03 09:44:37 2016 +0100
@@ -1720,6 +1720,20 @@
 	onError:aBlock
 !
 
+executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream auxFrom:anAuxStream inDirectory:dirOrNil lineWise:lineWise showWindow:showWindow onError:aBlock
+    ^ self
+        executeCommand:aCommandString
+        inputFrom:anInStream
+        outputTo:anOutStream
+        errorTo:anErrStream
+        auxFrom:anAuxStream
+        environment:nil
+        inDirectory:dirOrNil
+        lineWise:lineWise
+        showWindow:showWindow
+        onError:aBlock
+!
+
 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream environment:env onError:aBlock
     "execute the unix command specified by the argument, aCommandString.
      If aCommandString is a String, the commandString is passed to a shell for execution
@@ -1788,6 +1802,75 @@
     "Modified: / 10.11.1998 / 20:51:39 / cg"
 !
 
+executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream environment:env showWindow:showWindow onError:aBlock
+    "execute the unix command specified by the argument, aCommandString.
+     If aCommandString is a String, the commandString is passed to a shell for execution
+     - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
+     If aCommandString is an Array, the first element is the command to be executed,
+     and the other elements are the arguments to the command. No shell is invoked in this case.
+     Return true if successful, the value from aBlock if not.
+     If not successfull, aBlock is called with an OsProcessStatus
+     (containing the exit status) as argument."
+
+    ^ self
+        executeCommand:aCommandString
+        inputFrom:anInStream
+        outputTo:anOutStream
+        errorTo:anErrStream
+        auxFrom:nil
+        environment:env
+        inDirectory:nil
+        lineWise:false
+        showWindow:showWindow
+        onError:aBlock
+
+    "
+        OperatingSystem
+            executeCommand:'dir'
+            inputFrom:nil
+            outputTo:nil
+            errorTo:nil
+            onError:[:status | Transcript flash]
+
+        OperatingSystem
+            executeCommand:'foo'
+            inputFrom:nil
+            outputTo:nil
+            errorTo:nil
+            onError:[:status | Transcript flash]
+    "
+    "
+        |outStr errStr|
+
+        outStr := '' writeStream.
+        errStr := '' writeStream.
+        OperatingSystem
+            executeCommand:'ls'
+            inputFrom:nil
+            outputTo:outStr
+            errorTo:errStr
+            onError:[:status | Transcript flash].
+        Transcript show:'out:'; showCR:outStr contents.
+        Transcript show:'err:'; showCR:errStr contents.
+    "
+    "
+        |outStr errStr|
+
+        outStr := '' writeStream.
+        errStr := '' writeStream.
+        OperatingSystem
+            executeCommand:'ls /fooBar'
+            inputFrom:nil
+            outputTo:outStr
+            errorTo:errStr
+            onError:[:status | Transcript flash].
+        Transcript show:'out:'; showCR:outStr contents.
+        Transcript show:'err:'; showCR:errStr contents.
+    "
+
+    "Modified: / 10.11.1998 / 20:51:39 / cg"
+!
+
 executeCommand:aCommandString inputFrom:inputStreamOrNil outputTo:outStreamOrNil errorTo:errStreamOrNil inDirectory:aDirectory
     "much like #executeCommand:, but changes the current directory
      for the command. Since this is OS specific, use this instead of
@@ -1844,6 +1927,35 @@
 	onError:aBlock
 !
 
+executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream inDirectory:dirOrNil lineWise:lineWise showWindow:showWindow onError:aBlock
+    "execute the unix command specified by the argument, aCommandString.
+     If aCommandString is a String, the commandString is passed to a shell for execution
+     - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
+     If aCommandString is an Array, the first element is the command to be executed,
+     and the other elements are the arguments to the command. No shell is invoked in this case.
+     Return true if successful, the value from aBlock if not.
+     If not successfull, aBlock is called with an OsProcessStatus
+     (containing the exit status) as argument.
+     The given in, out and err streams may be arbitrary (Smalltalk-) streams;
+     if any is not an external stream (which is required by the command),
+     extra pipes and shuffler processes are created, which stuff the data into
+     those internal stream(s).
+     Nil stream args will execute the command connected to ST/X's standard input, output or
+     error resp. - i.e. usually, i/o will be from/to the terminal"
+
+    ^ self
+        executeCommand:aCommandString
+        inputFrom:anInStream
+        outputTo:anOutStream
+        errorTo:anErrStream
+        auxFrom:nil
+        environment:nil
+        inDirectory:dirOrNil
+        lineWise:lineWise
+        showWindow:showWindow
+        onError:aBlock
+!
+
 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream inDirectory:dirOrNil onError:aBlock
     "execute the unix command specified by the argument, aCommandString.
      If aCommandString is a String, the commandString is passed to a shell for execution
@@ -1983,6 +2095,75 @@
     "Modified: / 10.11.1998 / 20:51:39 / cg"
 !
 
+executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream showWindow:showWindow onError:aBlock
+    "execute the unix command specified by the argument, aCommandString.
+     If aCommandString is a String, the commandString is passed to a shell for execution
+     - see the description of 'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
+     If aCommandString is an Array, the first element is the command to be executed,
+     and the other elements are the arguments to the command. No shell is invoked in this case.
+     Return true if successful, the value from aBlock if not.
+     If not successfull, aBlock is called with an OsProcessStatus
+     (containing the exit status) as argument."
+
+    ^ self
+        executeCommand:aCommandString
+        inputFrom:anInStream
+        outputTo:anOutStream
+        errorTo:anErrStream
+        auxFrom:nil
+        environment:nil
+        inDirectory:nil
+        lineWise:false
+        showWindow:showWindow
+        onError:aBlock
+
+    "
+        OperatingSystem
+            executeCommand:'dir'
+            inputFrom:nil
+            outputTo:nil
+            errorTo:nil
+            onError:[:status | Transcript flash]
+
+        OperatingSystem
+            executeCommand:'foo'
+            inputFrom:nil
+            outputTo:nil
+            errorTo:nil
+            onError:[:status | Transcript flash]
+    "
+    "
+        |outStr errStr|
+
+        outStr := '' writeStream.
+        errStr := '' writeStream.
+        OperatingSystem
+            executeCommand:'ls'
+            inputFrom:nil
+            outputTo:outStr
+            errorTo:errStr
+            onError:[:status | Transcript flash].
+        Transcript show:'out:'; showCR:outStr contents.
+        Transcript show:'err:'; showCR:errStr contents.
+    "
+    "
+        |outStr errStr|
+
+        outStr := '' writeStream.
+        errStr := '' writeStream.
+        OperatingSystem
+            executeCommand:'ls /fooBar'
+            inputFrom:nil
+            outputTo:outStr
+            errorTo:errStr
+            onError:[:status | Transcript flash].
+        Transcript show:'out:'; showCR:outStr contents.
+        Transcript show:'err:'; showCR:errStr contents.
+    "
+
+    "Modified: / 10.11.1998 / 20:51:39 / cg"
+!
+
 executeCommand:aCommandString onError:aBlock
     "execute the unix command specified by the argument, aCommandString.
      If aCommandString is a String, the commandString is passed to a shell for execution