diff --git a/src/sbbs3/exec.cpp b/src/sbbs3/exec.cpp index 8659d549bdf8366a07d0a9de98e491ff36b9e52a..2e8512e401af01b36db5cfd29e1c9ecff9434728 100644 --- a/src/sbbs3/exec.cpp +++ b/src/sbbs3/exec.cpp @@ -1,10 +1,5 @@ -/* exec.cpp */ -// vi: tabstop=4 - /* Synchronet command shell/module interpretter */ -/* $Id: exec.cpp,v 1.116 2020/08/01 18:34:24 rswindell Exp $ */ - /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * @@ -18,21 +13,9 @@ * See the GNU General Public License for more details: gpl.txt or * * http://www.fsf.org/copyleft/gpl.html * * * - * Anonymous FTP access to the most recent released source is available at * - * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * - * * - * Anonymous CVS access to the development source and modification history * - * is available at cvs.synchro.net:/cvsroot/sbbs, example: * - * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login * - * (just hit return, no password is necessary) * - * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src * - * * * For Synchronet coding style and modification guidelines, see * * http://www.synchro.net/source.html * * * - * You are encouraged to submit any modifications (preferably in Unix diff * - * format) via e-mail to mods@synchro.net * - * * * Note: If this box doesn't appear square, then you need to fix your tabs. * ****************************************************************************/ @@ -594,6 +577,7 @@ long sbbs_t::js_execfile(const char *cmd, const char* startup_dir, JSObject* sco if(p!=NULL) { *p=0; args=p+1; + SKIP_WHITESPACE(args); } fname=cmdline; @@ -635,13 +619,17 @@ long sbbs_t::js_execfile(const char *cmd, const char* startup_dir, JSObject* sco JS_DefineProperty(js_cx, js_scope, "argv", OBJECT_TO_JSVAL(argv) ,NULL,NULL,JSPROP_READONLY|JSPROP_ENUMERATE); - /* TODO: Handle quoted "one arg" syntax here? */ + /* Handle quoted "one arg" syntax here */ if(args!=NULL && argv!=NULL) { while(*args) { - p=strchr(args,' '); + if(*args == '"') { + args++; + p = strchr(args, '"'); + } + else + p = strchr(args, ' '); if(p!=NULL) *p=0; - while(*args && *args==' ') args++; /* Skip spaces */ JSString* arg = JS_NewStringCopyZ(js_cx, args); if(arg==NULL) break; @@ -651,7 +639,8 @@ long sbbs_t::js_execfile(const char *cmd, const char* startup_dir, JSObject* sco argc++; if(p==NULL) /* last arg */ break; - args+=(strlen(args)+1); + args = p + 1; + SKIP_WHITESPACE(args); } } JS_DefineProperty(js_cx, js_scope, "argc", INT_TO_JSVAL(argc)