use wordexp instead of stringv_split for argument parsing

This commit is contained in:
josch
2014-09-17 08:31:08 +02:00
parent 540b603b41
commit fe42b6e668

View File

@@ -22,6 +22,7 @@
#include <string.h> #include <string.h>
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include <wordexp.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
@@ -109,8 +110,7 @@ _execute_shell_command(mfshell_t *mfshell,char *command)
extern int term_height; extern int term_height;
extern int term_width; extern int term_width;
char **argv = NULL; wordexp_t p;
int argc = 0;
int retval; int retval;
if(mfshell == NULL) return -1; if(mfshell == NULL) return -1;
@@ -131,15 +131,13 @@ _execute_shell_command(mfshell_t *mfshell,char *command)
return -1; return -1;
} }
argv = stringv_split(command," ",5); // FIXME: handle non-zero return value of wordexp
if(argv == NULL) return -1; retval = wordexp(command, &p, WRDE_SHOWERR | WRDE_UNDEF);
argc = stringv_len(argv);
// TODO: handle retval // TODO: handle retval
retval = _execute(mfshell, argc, argv); retval = _execute(mfshell, p.we_wordc, p.we_wordv);
stringv_free(argv,STRINGV_FREE_ALL); wordfree(&p);
return 0; return 0;
} }