Browse Source

Fix __intaractive var generation. The right way without fictive param.

git-svn-id: https://klish.googlecode.com/svn/trunk@473 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
0003118c8c
4 changed files with 6 additions and 18 deletions
  1. 0 1
      clish/shell/private.h
  2. 1 11
      clish/shell/shell_new.c
  3. 0 6
      clish/shell/shell_parse.c
  4. 5 0
      clish/shell/shell_var.c

+ 0 - 1
clish/shell/private.h

@@ -61,7 +61,6 @@ struct clish_shell_s {
 	/* Static params for var expanding. The refactoring is needed. */
 	clish_param_t *param_depth;
 	clish_param_t *param_pwd;
-	clish_param_t *param_interactive;
 };
 
 /**

+ 1 - 11
clish/shell/shell_new.c

@@ -70,16 +70,7 @@ static void clish_shell_init(clish_shell_t * this,
 	this->param_pwd = clish_param_new("__cur_pwd",
 		"Current path", tmp_ptype);
 	clish_param__set_hidden(this->param_pwd, BOOL_TRUE);
-	/* Interactive */
-	tmp_ptype = clish_shell_find_create_ptype(this,
-		"__INTERACTIVE", "Interactive flag", "[01]",
-		CLISH_PTYPE_REGEXP, CLISH_PTYPE_NONE);
-	assert(tmp_ptype);
-	this->param_interactive = clish_param_new("__interactive",
-		"Interactive flag", tmp_ptype);
-	clish_param__set_hidden(this->param_interactive, BOOL_TRUE);
-
-	/* PTYPE for args */
+	/* Args */
 	tmp_ptype = clish_shell_find_create_ptype(this,
 		"internal_ARGS",
 		"Arguments", "[^\\]+",
@@ -141,7 +132,6 @@ static void clish_shell_fini(clish_shell_t * this)
 	/* Free internal params */
 	clish_param_delete(this->param_depth);
 	clish_param_delete(this->param_pwd);
-	clish_param_delete(this->param_interactive);
 
 	lub_string_free(this->lockfile);
 	lub_string_free(this->default_shebang);

+ 0 - 6
clish/shell/shell_parse.c

@@ -53,12 +53,6 @@ clish_pargv_status_t clish_shell_parse(
 			clish_pargv_insert(*pargv, this->param_pwd, tmp);
 			lub_string_free(tmp);
 		}
-		/* Variable __interactive */
-		if (clish_shell__get_interactive(this))
-			tmp = "1";
-		else
-			tmp = "0";
-		clish_pargv_insert(*pargv, this->param_interactive, tmp);
 	}
 
 	return result;

+ 5 - 0
clish/shell/shell_var.c

@@ -66,6 +66,11 @@ static char *find_context_var(const char *name, clish_context_t *this)
 	} else if (!lub_string_nocasecmp(name, "__params")) {
 		if (this->pargv)
 			result = clish_shell__get_params(this);
+	} else if (!lub_string_nocasecmp(name, "__interactive")) {
+		if (clish_shell__get_interactive(this->shell))
+			result = strdup("1");
+		else
+			result = strdup("0");
 	} else if (lub_string_nocasestr(name, "__prefix") == name) {
 		int idx = 0;
 		int pnum = 0;