AbstractOperatingSystem.st
changeset 23255 f1e0a3edca55
parent 23203 8d74e1a4c65f
child 23256 966ae73cc387
--- a/AbstractOperatingSystem.st	Wed Aug 01 22:41:31 2018 +0200
+++ b/AbstractOperatingSystem.st	Thu Aug 02 11:07:30 2018 +0200
@@ -2444,17 +2444,17 @@
 !
 
 getCommandOutputFrom:aCommand
-    "execute a simple command (such as hostname) and
-     return the commands first line of output as a string (forget stdErr).
+    "execute a simple command (such as 'hostname') and
+     return the command's 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 does not generate any output, an empty string is returned;
      if the command fails, nil is returned."
 
     |result|
 
     result := self getCommandOutputFrom:aCommand maxNumberOfLines:1 errorDisposition:#discard.
     result notNil ifTrue:[
-	^ result firstIfEmpty:['']
+        ^ result firstIfEmpty:['']
     ].
     ^ result
 
@@ -2465,15 +2465,16 @@
      OperatingSystem getCommandOutputFrom:'foo'
     "
 
+    "Modified (comment): / 02-08-2018 / 11:05:52 / Claus Gittinger"
 !
 
 getCommandOutputFrom:aCommand maxNumberOfLines:numLinesOrNil errorDisposition:errorDisposition
-    "execute a simple command (such as hostname) and
-     return the commands output as a collection of strings,
+    "execute a simple command (such as 'ls') and
+     return the command's 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 does not generate any output, an empty string 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).
@@ -2485,30 +2486,30 @@
     |result|
 
     PipeFailed ~~ true ifTrue:[
-	PipeStream openErrorSignal handle:[:ex |
-	    PipeFailed := true.
-	    'OperatingSystem [warning]: cannot fork/popen' errorPrintCR.
-	    ex return.
-	] do:[
-	    |p line|
-
-	    p := PipeStream
-		    readingFrom:aCommand
-		    errorDisposition:errorDisposition
-		    inDirectory:nil.
-	    result := StringCollection new.
-	    [p atEnd] whileFalse:[
-		line := p nextLine.
-		(numLinesOrNil isNil
-		or:[result size < numLinesOrNil]) ifTrue:[
-		    result add:line
-		].
-	    ].
-	    p close.
-	    (p exitStatus notNil and:[p exitStatus success]) ifFalse:[
-		result := result asNilIfEmpty
-	    ].
-	].
+        PipeStream openErrorSignal handle:[:ex |
+            PipeFailed := true.
+            'OperatingSystem [warning]: cannot fork/popen' errorPrintCR.
+            ex return.
+        ] do:[
+            |p line|
+
+            p := PipeStream
+                    readingFrom:aCommand
+                    errorDisposition:errorDisposition
+                    inDirectory:nil.
+            result := StringCollection new.
+            [p atEnd] whileFalse:[
+                line := p nextLine.
+                (numLinesOrNil isNil
+                or:[result size < numLinesOrNil]) ifTrue:[
+                    result add:line
+                ].
+            ].
+            p close.
+            (p exitStatus notNil and:[p exitStatus success]) ifFalse:[
+                result := result asNilIfEmpty
+            ].
+        ].
     ].
     ^ result
 
@@ -2519,13 +2520,14 @@
      OperatingSystem getCommandOutputFrom:'foo' maxNumberOfLines:nil
     "
 
-    "Modified: / 19.5.1999 / 14:25:02 / cg"
+    "Modified: / 19-05-1999 / 14:25:02 / cg"
+    "Modified (comment): / 02-08-2018 / 11:05:24 / Claus Gittinger"
 !
 
 getFullCommandOutputFrom:aCommand
     "execute a command and
-     return the commands output as a collection of strings (ignoring stdErr).
-     If the commands does not generate any output, an empty string is returned;
+     return the command's output as a collection of strings (ignoring stdErr).
+     If the command does not generate any output, an empty string is returned;
      if the command fails, nil is returned."
 
     ^ self getCommandOutputFrom:aCommand maxNumberOfLines:nil errorDisposition:#discard
@@ -2534,6 +2536,7 @@
      OperatingSystem getFullCommandOutputFrom:'mt status'
     "
 
+    "Modified (comment): / 02-08-2018 / 11:05:39 / Claus Gittinger"
 ! !
 
 !AbstractOperatingSystem class methodsFor:'executing OS commands-queries'!