AbstractOperatingSystem.st
changeset 5482 433983048ce8
parent 5480 92eb8594f437
child 5483 1d81b1ad42d0
--- a/AbstractOperatingSystem.st	Tue Jul 25 16:13:57 2000 +0200
+++ b/AbstractOperatingSystem.st	Tue Jul 25 16:15:27 2000 +0200
@@ -1466,14 +1466,14 @@
 
 getCommandOutputFrom:aCommand
     "execute a simple command (such as hostname) and
-     return the commands first line of output as a string.
+     return the commands first line of output as a string (forget stdErr).
      If the command generates multiple output lines, only the first line is returned.
      If the commands does not generate any output, an empty string is returned;
      if the command fails, nil is returned."
 
     |result|
 
-    result := self getCommandOutputFrom:aCommand maxNumberOfLines:1.
+    result := self getCommandOutputFrom:aCommand maxNumberOfLines:1 errorDisposition:#discard.
     result notNil ifTrue:[
         ^ result firstIfEmpty:['']
     ].
@@ -1488,14 +1488,20 @@
 
 !
 
-getCommandOutputFrom:aCommand maxNumberOfLines:numLinesOrNil
+getCommandOutputFrom:aCommand maxNumberOfLines:numLinesOrNil errorDisposition:errorDisposition
     "execute a simple command (such as hostname) and
      return the commands output as a collection of strings,
      but only up to the given number of lines (if non-nil).
      If the command generates more output, only the first nLines are returned
      (but the command is allowed to finish execution).
      If the commands does not generate any output, an empty string is returned;
-     if the command fails, nil is returned."
+     if the command fails, nil is returned.
+     errorDisposition controls where the stdErr output should go,
+     and may be one of #discard, #inline or #stderr (default).
+     #discard causes stderr to be discarded (/dev/null), 
+     #inline causes it to be written to smalltalks own stdout and
+     #stderr causes it to be written to smalltalks own stderr.
+     Nil is treated like #stderr"
 
     |result|
 
@@ -1509,7 +1515,7 @@
 
             p := PipeStream 
                     readingFrom:aCommand
-                    errorDisposition:#discard
+                    errorDisposition:errorDisposition
                     inDirectory:nil.
             p notNil ifTrue:[
                 result := StringCollection new.
@@ -1542,12 +1548,12 @@
 !
 
 getFullCommandOutputFrom:aCommand
-    "execute a simple command (such as hostname) and
-     return the commands output as a collection of strings.
+    "execute a command and
+     return the commands output as a collection of strings (including stdErr).
      If the commands does not generate any output, an empty string is returned;
      if the command fails, nil is returned."
 
-    ^ self getCommandOutputFrom:aCommand maxNumberOfLines:nil
+    ^ self getCommandOutputFrom:aCommand maxNumberOfLines:nil errorDisposition:#inline
 
     "
      OperatingSystem getFullCommandOutputFrom:'mt status'
@@ -4232,6 +4238,6 @@
 !AbstractOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.41 2000-07-25 10:47:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.42 2000-07-25 14:15:27 cg Exp $'
 ! !
 AbstractOperatingSystem initialize!