Browse Source

PTYPE's ACTIONS are permnent

Serj Kalichev 4 years ago
parent
commit
eacd10057e
5 changed files with 13 additions and 1 deletions
  1. 2 0
      clish/action.h
  2. 3 0
      clish/action/action.c
  3. 1 0
      clish/action/private.h
  4. 4 0
      clish/ptype/ptype.c
  5. 3 1
      clish/shell/shell_execute.c

+ 2 - 0
clish/action.h

@@ -26,5 +26,7 @@ _CLISH_SET(action, bool_t, interrupt);
 _CLISH_GET(action, bool_t, interrupt);
 _CLISH_SET(action, bool_t, interactive);
 _CLISH_GET(action, bool_t, interactive);
+_CLISH_SET(action, bool_t, permanent);
+_CLISH_GET(action, bool_t, permanent);
 
 #endif // _clish_action_h

+ 3 - 0
clish/action/action.c

@@ -20,6 +20,7 @@ static void clish_action_init(clish_action_t *this)
 	this->shebang = NULL;
 	this->lock = BOOL_TRUE;
 	this->interrupt = BOOL_FALSE;
+	this->permanent = BOOL_FALSE;
 }
 
 /*--------------------------------------------------------- */
@@ -57,6 +58,8 @@ CLISH_SET(action, bool_t, interrupt);
 CLISH_GET(action, bool_t, interrupt);
 CLISH_SET(action, bool_t, interactive);
 CLISH_GET(action, bool_t, interactive);
+CLISH_SET(action, bool_t, permanent);
+CLISH_GET(action, bool_t, permanent);
 
 _CLISH_SET_STR(action, shebang)
 {

+ 1 - 0
clish/action/private.h

@@ -11,4 +11,5 @@ struct clish_action_s {
 	bool_t lock;
 	bool_t interrupt;
 	bool_t interactive;
+	bool_t permanent; // if true then ACTION will be executed on dryrun
 };

+ 4 - 0
clish/ptype/ptype.c

@@ -35,6 +35,10 @@ static void clish_ptype_init(clish_ptype_t * this,
 	this->preprocess = preprocess;
 	this->range = NULL;
 	this->action = clish_action_new();
+	// PTYPE's ACTION must be 'permanent' i.e. it must be executed whenever
+	// it's a dryrun klish mode or not. Because argument checking is always
+	// needed.
+	clish_action__set_permanent(this->action, BOOL_TRUE);
 
 	if (pattern) {
 		/* set the pattern for this type */

+ 3 - 1
clish/shell/shell_execute.c

@@ -314,7 +314,9 @@ int clish_shell_exec_action(clish_context_t *context, char **out)
 
 	if (!(sym = clish_action__get_builtin(action)))
 		return 0;
-	if (shell->dryrun && !clish_sym__get_permanent(sym))
+	if (shell->dryrun &&
+		!clish_sym__get_permanent(sym) &&
+		!clish_action__get_permanent(action))
 		return 0;
 	if (!(func = clish_sym__get_func(sym))) {
 		fprintf(stderr, "Error: Default ACTION symbol is not specified.\n");