浏览代码

The internal variables is available for 'test' in the nested parameters.

git-svn-id: https://klish.googlecode.com/svn/trunk@252 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 年之前
父节点
当前提交
e1d3d3592d
共有 2 个文件被更改,包括 11 次插入5 次删除
  1. 10 4
      clish/pargv/pargv.c
  2. 1 1
      clish/shell/shell_parse.c

+ 10 - 4
clish/pargv/pargv.c

@@ -110,8 +110,14 @@ clish_pargv_parse(clish_pargv_t * this,
 	unsigned i;
 	clish_pargv_status_t retval;
 	unsigned paramc = clish_paramv__get_count(paramv);
+	int up_level = 0; /* Is it a first level of param nesting? */
 
 	assert(this);
+	assert(cmd);
+
+	/* Check is it a first level of PARAM nesting. */
+	if (paramv == clish_command__get_paramv(cmd))
+		up_level = 1;
 
 	while (index < paramc) {
 		const char *arg;
@@ -243,7 +249,7 @@ clish_pargv_parse(clish_pargv_t * this,
 
 				/* Walk through the nested parameters */
 				if (rec_paramc) {
-					retval = clish_pargv_parse(this, NULL,
+					retval = clish_pargv_parse(this, cmd,
 						viewid, rec_paramv,
 						argv, idx, last, need_index);
 					if (CLISH_LINE_OK != retval)
@@ -290,8 +296,8 @@ clish_pargv_parse(clish_pargv_t * this,
 	 * params than it's a args. So generate the args entry
 	 * in the list of completions.
 	 */
-	if (last &&
-			cmd && clish_command__get_args(cmd) &&
+	if (last && up_level &&
+			clish_command__get_args(cmd) &&
 			(clish_pargv__get_count(last) == 0) &&
 			(*idx <= argc) && (index >= paramc)) {
 		clish_pargv_insert(last, clish_command__get_args(cmd), "");
@@ -301,7 +307,7 @@ clish_pargv_parse(clish_pargv_t * this,
 	 * if we've satisfied all the parameters we can now construct
 	 * an 'args' parameter if one exists
 	 */
-	if (cmd && (*idx < argc) && (index >= paramc)) {
+	if (up_level && (*idx < argc) && (index >= paramc)) {
 		const char *arg = lub_argv__get_arg(argv, *idx);
 		const clish_param_t *param = clish_command__get_args(cmd);
 		char *args = NULL;

+ 1 - 1
clish/shell/shell_parse.c

@@ -10,7 +10,7 @@ clish_pargv_status_t clish_shell_parse(
 	const clish_shell_t * this, const char *line,
 	const clish_command_t ** cmd, clish_pargv_t ** pargv)
 {
- 	clish_pargv_status_t result = CLISH_BAD_CMD;
+	clish_pargv_status_t result = CLISH_BAD_CMD;
 
 	*cmd = clish_shell_resolve_command(this, line);
 	/* Now construct the parameters for the command */