-LD_OPTS += -lobjson -lreadline -lxml2 -lopensrf_transport -lopensrf_stack -lncurses -lc_utils
+# if EXEC_DEFAULT is defined, then srfsh will send all unknown commands to the shell for execution
+
+LD_OPTS += -lobjson -lreadline -lxml2 -lopensrf_transport -lopensrf_stack -lncurses -lc_utils -DEXEC_DEFAULT
all: srfsh
if( ! words )
return 0;
+
int i = 0;
char* current;
char buffer[256];
else if (words[0][0] == '!')
ret_val = handle_exec( words );
- if(!ret_val)
- return parse_error( words );
+ if(!ret_val) {
+ #ifdef EXEC_DEFAULT
+ return handle_exec( words );
+ #else
+ return parse_error( words );
+ #endif
+ }
return 1;
int handle_exec(char* words[]) {
- int len = strlen(words[0]);
- char command[len];
- memset(command,0,len);
+ if(!words[0]) return 0;
- int i; /* chop out the ! */
- for( i=1; i!= len; i++) {
- command[i-1] = words[0][i];
+ if( words[0] && words[0][0] == '!') {
+ int len = strlen(words[0]);
+ char command[len];
+ memset(command,0,len);
+
+ int i; /* chop out the ! */
+ for( i=1; i!= len; i++) {
+ command[i-1] = words[0][i];
+ }
+
+ free(words[0]);
+ words[0] = strdup(command);
}
- free(words[0]);
- words[0] = strdup(command);
signal(SIGCHLD,sig_child_handler);
+
if(fork()) {
- while(1) {
- sleep(100);
- if(child_dead) {
- signal(SIGCHLD,sig_child_handler);
- child_dead = 0;
- break;
- }
+
+ waitpid(-1, 0, 0);
+ if(child_dead) {
+ signal(SIGCHLD,sig_child_handler);
+ child_dead = 0;
}
+
} else {
execvp( words[0], words );
exit(0);
#include "opensrf/osrf_config.h"
#include <time.h>
#include <sys/timeb.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include "md5.h"
#include "utils.h"
/* true if we're pretty printing json results */
int pretty_print = 1;
+int raw_print = 0;
/* our jabber connection */
transport_client* client = NULL;