Skip to content

Commit

Permalink
Issue #58: oops missed a few new methods [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
dalehenrich committed Mar 20, 2015
1 parent 472d2a2 commit 83c8c7b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
accessing
runShellCommand: shellCommandPath args: shellArgumentArray noError: noError
| out err proc outName errName pid success stdOut stdErr |
pid := OSProcess thisOSProcess pid.
outName := '/tmp/gsdevkit' , pid printString , '.out'.
out := FileStream forceNewFileNamed: outName.
errName := '/tmp/gsdevkit' , pid printString , '.err'.
err := FileStream forceNewFileNamed: errName.
proc := OSProcess thisOSProcess
forkJob: shellCommandPath
arguments: shellArgumentArray
environment: nil
descriptors: (Array with: nil with: out with: err).
proc ifNil: [ OSProcess noAccessorAvailable ].
[ proc isRunning ] whileTrue: [ (Delay forMilliseconds: 100) wait ].
success := proc succeeded.
out close.
err close.
FileStream readOnlyFileNamed: outName do: [ :fileStream | stdOut := fileStream contents ].
FileStream readOnlyFileNamed: errName do: [ :fileStream | stdErr := fileStream contents ].
success
ifFalse: [
Transcript
cr;
show: 'Error running shell command: ' , shellCommandPath printString;
cr;
show: 'with args:'.
shellArgumentArray
do: [ :arg |
Transcript
cr;
tab;
show: arg ].
Transcript
cr;
show: 'STDOUT: ' , stdOut printString;
cr;
show: 'STDERR: ' , stdErr.
noError
ifFalse: [ self error: 'Shell command: ' , shellCommandPath printString , ' failed.' ] ].
^ stdOut
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
runShellCommand: shellCommandPath args: shellArgumentArray noError: noError
^ self class runShellCommand: shellCommandPath args: shellArgumentArray noError: noError

0 comments on commit 83c8c7b

Please sign in to comment.