aboutsummaryrefslogtreecommitdiff
path: root/src/functionexecute.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-08 22:58:28 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-08 22:58:28 +0000
commit52be1ef0d126f09ba943c7afcf367e7d9347f2fd (patch)
treefd4b0dd148751c3c6c1b95296c3b82cb86051b83 /src/functionexecute.cpp
parent795d0737fed40d88a7801b451b7750ba90802345 (diff)
downloadbuild-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.tar.gz
build-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.tar.bz2
build-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.tar.xz
build-52be1ef0d126f09ba943c7afcf367e7d9347f2fd.zip
tabconv: it's all spaces now.
Diffstat (limited to '')
-rw-r--r--src/functionexecute.cpp90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/functionexecute.cpp b/src/functionexecute.cpp
index 070ca53..cad65fa 100644
--- a/src/functionexecute.cpp
+++ b/src/functionexecute.cpp
@@ -8,7 +8,7 @@ using namespace Bu;
8 8
9#include <bu/plugger.h> 9#include <bu/plugger.h>
10PluginInterface3( pluginFunctionExecute, execute, FunctionExecute, Function, 10PluginInterface3( pluginFunctionExecute, execute, FunctionExecute, Function,
11 "Mike Buland", 0, 1 ); 11 "Mike Buland", 0, 1 );
12 12
13FunctionExecute::FunctionExecute() 13FunctionExecute::FunctionExecute()
14{ 14{
@@ -20,54 +20,54 @@ FunctionExecute::~FunctionExecute()
20 20
21Bu::String FunctionExecute::getName() const 21Bu::String FunctionExecute::getName() const
22{ 22{
23 return "execute"; 23 return "execute";
24} 24}
25 25
26Variable FunctionExecute::call( Variable &/*input*/, VarList lParams ) 26Variable FunctionExecute::call( Variable &/*input*/, VarList lParams )
27{ 27{
28 // TODO This is lame, really lame, we need to exec on our own and process 28 // TODO This is lame, really lame, we need to exec on our own and process
29 // output appropriately. 29 // output appropriately.
30 pContext->getView()->cmdStarted( lParams.first().getString() ); 30 pContext->getView()->cmdStarted( lParams.first().getString() );
31 Process pCmd( Process::Both, "/bin/bash", "/bin/bash", "-c", 31 Process pCmd( Process::Both, "/bin/bash", "/bin/bash", "-c",
32 lParams.first().getString().getStr(), NULL ); 32 lParams.first().getString().getStr(), NULL );
33 String sStdOut, sStdErr; 33 String sStdOut, sStdErr;
34 do 34 do
35 { 35 {
36 char buf[4096]; 36 char buf[4096];
37 bool out, err; 37 bool out, err;
38 pCmd.select( out, err ); 38 pCmd.select( out, err );
39 if( err ) 39 if( err )
40 { 40 {
41 int iRead = pCmd.readErr( buf, 4096 ); 41 int iRead = pCmd.readErr( buf, 4096 );
42 sStdErr.append( buf, iRead ); 42 sStdErr.append( buf, iRead );
43 //sio << "Read " << iRead << " bytes of stderr." << sio.nl; 43 //sio << "Read " << iRead << " bytes of stderr." << sio.nl;
44 } 44 }
45 if( out ) 45 if( out )
46 { 46 {
47 int iRead = pCmd.read( buf, 4096 ); 47 int iRead = pCmd.read( buf, 4096 );
48 sStdOut.append( buf, iRead ); 48 sStdOut.append( buf, iRead );
49 //sio << "Read " << iRead << " bytes of stdout." << sio.nl; 49 //sio << "Read " << iRead << " bytes of stdout." << sio.nl;
50 } 50 }
51 } 51 }
52 while( pCmd.isRunning() ); 52 while( pCmd.isRunning() );
53 53
54 pContext->getView()->cmdFinished( 54 pContext->getView()->cmdFinished(
55 sStdOut, sStdErr, pCmd.childExitStatus() 55 sStdOut, sStdErr, pCmd.childExitStatus()
56 ); 56 );
57 if( pCmd.childExited() ) 57 if( pCmd.childExited() )
58 { 58 {
59 if( pCmd.childExitStatus() != 0 ) 59 if( pCmd.childExitStatus() != 0 )
60 { 60 {
61 throw Bu::ExceptionBase("Command exited with errorcode %d.", pCmd.childExitStatus() ); 61 throw Bu::ExceptionBase("Command exited with errorcode %d.", pCmd.childExitStatus() );
62 } 62 }
63 } 63 }
64 else 64 else
65 { 65 {
66 pContext->getView()->cmdFinished( 66 pContext->getView()->cmdFinished(
67 sStdOut, sStdErr, pCmd.childExitStatus() 67 sStdOut, sStdErr, pCmd.childExitStatus()
68 ); 68 );
69 throw Bu::ExceptionBase("Command Failed"); 69 throw Bu::ExceptionBase("Command Failed");
70 } 70 }
71 return Variable( pCmd.childExitStatus() ); 71 return Variable( pCmd.childExitStatus() );
72} 72}
73 73