From 93379cc552745c579a5177b6cc94e3bbb20f33bc Mon Sep 17 00:00:00 2001 From: Kolja Waschk Date: Sun, 25 Nov 2007 13:08:27 +0000 Subject: [PATCH] Allow arbitrary number of arguments for "shell" command (fix for [1837985] "shell" command causes segfault) git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@785 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/src/cmd/shell.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/jtag/src/cmd/shell.c b/jtag/src/cmd/shell.c index a1ba2bd7..ee1db899 100644 --- a/jtag/src/cmd/shell.c +++ b/jtag/src/cmd/shell.c @@ -24,7 +24,11 @@ #include "sysdep.h" -//#include +#include +#include +#include + +#include #include #include //#include "part.h" @@ -36,8 +40,8 @@ static int cmd_shell_run( char *params[] ) { -int n,l1,l2; -char *t; + int i, len, n = cmd_params(params); + char *shell_cmd; if((n=cmd_params( params )) == 1) return -1; @@ -46,17 +50,30 @@ char *t; * the following. If you can pass a shell argument past strtok the * please fix this. */ + /* The problem is the parser which splits commands into params[] + * and doesn't allow quoting. So we concatenate the params[] here + * with single spaces, although the original might have different + * whitespace (more than one space, tabs, ...) - kawk */ + + for(i=1,len=0; i