-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #58: oops missed a few new methods [ci skip]
- Loading branch information
1 parent
472d2a2
commit 83c8c7b
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...e.package/GsDevKitAbstractCommandLineHandler.class/class/runShellCommand.args.noError..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
3 changes: 3 additions & 0 deletions
3
...ackage/GsDevKitAbstractCommandLineHandler.class/instance/runShellCommand.args.noError..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |