diff --git a/doc/remote.txt b/doc/remote.txt index 587bda7a..dfe92ba3 100644 --- a/doc/remote.txt +++ b/doc/remote.txt @@ -10,7 +10,10 @@ When invoking ELinks with the -remote argument, it does not start a new instance, but instead connects to an already running ELinks, making it possible to control that ELinks instance. The -remote command line switch takes a command consisting of the action to invoke and any parameters to the -action. Here is an example for opening freshmeat.net in a new tab: +action. Commands must begin with a nonempty sequence of ASCII alphabetic +characters followed by optional whitespace and an opening parenthesis. They +must end with a closing parenthesis optionally followed by whitespace. Here is +an example for opening freshmeat.net in a new tab: $ elinks -remote "openURL(http://freshmeat.net/, new-tab)" diff --git a/src/config/cmdline.c b/src/config/cmdline.c index 113287f6..b32dccbb 100644 --- a/src/config/cmdline.c +++ b/src/config/cmdline.c @@ -218,7 +218,7 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc) { "xfeDoCommand", REMOTE_METHOD_XFEDOCOMMAND }, { NULL, REMOTE_METHOD_NOT_SUPPORTED }, }; - unsigned char *command, *arg, *argend = NULL; + unsigned char *command, *arg, *argend; int method, len = 0; if (*argc < 1) return gettext("Parameter expected"); @@ -228,20 +228,27 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc) while (isalpha(command[len])) len++; - arg = strchr(&command[len], '('); - if (arg) { - arg++; - skip_space(arg); + /* Find the begining and end of the argument list. */ - argend = strchr(arg, ')'); - } + arg = command + len; + skip_space(arg); - if (!argend) { + argend = arg + strlen(arg); + skipback_whitespace(arg, argend); + if (argend > arg) + argend--; + + /* Decide whether to use the "extended" --remote format where + * all URLs following should be opened in tabs. */ + if (*arg != '(' || *argend != ')') { /* Just open any passed URLs in new tabs */ remote_session_flags |= SES_REMOTE_NEW_TAB; return NULL; } + /* Skip parenthesis and surrounding whitespace. */ + arg++; + skip_space(arg); skipback_whitespace(arg, argend); for (method = 0; remote_methods[method].name; method++) {