Ver código fonte

The functions like forceline() return retval now instead bool value. The testing is needed.

git-svn-id: https://klish.googlecode.com/svn/trunk@476 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 anos atrás
pai
commit
3f64c50e64

+ 3 - 3
bin/clish.cpp

@@ -49,7 +49,7 @@ static void help(int status, const char *argv0);
 /*--------------------------------------------------------- */
 int main(int argc, char **argv)
 {
-	bool_t running;
+	int running;
 	int result = -1;
 	clish_shell_t * shell;
 
@@ -208,7 +208,7 @@ int main(int argc, char **argv)
 	}
 	/* Execute startup */
 	running = clish_shell_startup(shell);
-	if (!running) {
+	if (running) {
 		fprintf(stderr, "Cannot startup clish.\n");
 		clish_shell_delete(shell);
 		return -1;
@@ -230,7 +230,7 @@ int main(int argc, char **argv)
 	if (quiet)
 		fclose(outfd);
 
-	return result ? 0 : -1;
+	return result;
 }
 
 /*--------------------------------------------------------- */

+ 4 - 5
clish/callback_script.c

@@ -1,7 +1,6 @@
 /*
  * clish_script_callback.c
  *
- *
  * Callback hook to action a shell script.
  */
 #include <stdio.h>
@@ -21,7 +20,7 @@
 #include "internal.h"
 
 /*--------------------------------------------------------- */
-bool_t clish_script_callback(clish_context_t *context,
+int clish_script_callback(clish_context_t *context,
 	const char *script, char **out)
 {
 	clish_shell_t *this = context->shell;
@@ -147,11 +146,11 @@ bool_t clish_script_callback(clish_context_t *context,
 #ifdef DEBUG
 	fprintf(stderr, "RETCODE: %d\n", WEXITSTATUS(res));
 #endif /* DEBUG */
-	return (0 == res) ? BOOL_TRUE : BOOL_FALSE;
+	return WEXITSTATUS(res);
 }
 
 /*--------------------------------------------------------- */
-bool_t clish_dryrun_callback(clish_context_t *context,
+int clish_dryrun_callback(clish_context_t *context,
 	const char *script, char ** out)
 {
 #ifdef DEBUG
@@ -160,7 +159,7 @@ bool_t clish_dryrun_callback(clish_context_t *context,
 	if (out)
 		*out = NULL;
 
-	return BOOL_TRUE;
+	return 0;
 }
 
 /*--------------------------------------------------------- */

+ 13 - 59
clish/shell.h

@@ -142,17 +142,16 @@ typedef void clish_shell_cmd_line_fn_t(
   * that the call doesn't return until the script has been fully evaluated.
   * 
   * \return 
-  * - BOOL_TRUE  - if the script is executed without issue
-  * - BOOL_FALSE - if the script had an issue with execution.
+  * - Retval (int)
   *
   * \post
   * - If the script executes successfully then any "view" tag associated with the
   *   command will be honored. i.e. the CLI will switch to the new view
   */
-typedef bool_t clish_shell_script_fn_t(
+typedef int clish_shell_script_fn_t(
 	clish_context_t *context,
 	const char *script,
-	char ** out);
+	char **out);
 
 /**
   * A hook function used to control config file write
@@ -203,11 +202,10 @@ typedef bool_t clish_shell_access_fn_t(
   * clish_shell_builtin_cmds_t structure.
   *
   * \return
-  * - BOOL_TRUE  - if the command completes correctly
-  * - BOOL_FALSE - if the command fails.
+  * - Retval (int)
   *
   */
-typedef bool_t clish_shell_builtin_fn_t(
+typedef int clish_shell_builtin_fn_t(
 	/** 
          * The shell instance which invoked this call
          */
@@ -247,48 +245,6 @@ typedef struct {
  * meta functions
  *----------------- */
 
-#if 0
-int clish_shell_spawn_and_wait(const clish_shell_hooks_t * hooks, void *cookie);
- /**
-  * This operation causes a separate (POSIX) thread of execution to 
-  * be spawned. This thread becomes responsible for the CLI session.
-  * 
-  * This will be invoked from the context of the spawned shell's thread
-  * and will be called during the execution of a builting command.
-  * 
-  * A client may register any number of these callbacks in its 
-  * clish_shell_builtin_cmds_t structure.
-  *
-  * \return
-  * - BOOL_TRUE  - if the thread was successfully spawned
-  * - BOOL_FALSE - if the thread failed to be spawned
-  *
-  */
-bool_t clish_shell_spawn(
-	/** 
-         * A POSIX thread reference to fill out. This can be used
-         * to later control the spawned thread if necessary.
-         */
-				pthread_t * pthread,
-	/** 
-         * A POSIX thread attribute reference which will be used
-         * to define the thread which will be lanched. A value of
-         * NULL will use the system default.
-         */
-				const pthread_attr_t * attr,
-	/** 
-          * A reference to the clients hooks. These are used to 
-          * communicate back the client when client-specific actions
-          * are required.
-          */
-				const clish_shell_hooks_t * hooks,
-	/** 
-         * A client specific reference which can be obtained during
-         * a callback by invoking clish_shell__get_client_cookie()
-         */
-				void *cookie);
-#endif
-
 clish_shell_t *clish_shell_new(const clish_shell_hooks_t * hooks,
 	void *cookie,
 	FILE * istream,
@@ -300,7 +256,7 @@ clish_shell_t *clish_shell_new(const clish_shell_hooks_t * hooks,
 /*
  * Called to invoke the startup command for this shell
  */
-bool_t clish_shell_startup(clish_shell_t * instance);
+int clish_shell_startup(clish_shell_t * instance);
 void clish_shell_delete(clish_shell_t * instance);
 clish_view_t *clish_shell_find_create_view(clish_shell_t * instance,
 	const char *name,
@@ -315,13 +271,11 @@ clish_ptype_t *clish_shell_find_ptype(clish_shell_t *instance,
 	const char *name);
 int clish_shell_xml_read(clish_shell_t * instance, const char *filename);
 void clish_shell_help(clish_shell_t * instance, const char *line);
-bool_t clish_shell_exec_action(clish_action_t *action,
+int clish_shell_exec_action(clish_action_t *action,
 	clish_context_t *context, char **out);
-bool_t clish_shell_execute(clish_context_t *context, char **out);
-bool_t clish_shell_line(clish_shell_t * instance, const char *prompt,
-	const clish_command_t ** cmd, clish_pargv_t ** pargv, const char *str);
-bool_t clish_shell_forceline(clish_shell_t *instance, const char *line, char ** out);
-bool_t clish_shell_readline(clish_shell_t *instance, char ** out);
+int clish_shell_execute(clish_context_t *context, char **out);
+int clish_shell_forceline(clish_shell_t *instance, const char *line, char ** out);
+int clish_shell_readline(clish_shell_t *instance, char ** out);
 void clish_shell_dump(clish_shell_t * instance);
 void clish_shell_close(clish_shell_t * instance);
 /**
@@ -333,9 +287,9 @@ void clish_shell_close(clish_shell_t * instance);
  * BOOL_TRUE - the file was successfully associated with the shell.
  * BOOL_FALSE - there was insufficient resource to associate this file.
  */
-bool_t clish_shell_push_file(clish_shell_t * instance, const char * fname,
+int clish_shell_push_file(clish_shell_t * instance, const char * fname,
 	bool_t stop_on_error);
-bool_t clish_shell_push_fd(clish_shell_t * instance, FILE * file,
+int clish_shell_push_fd(clish_shell_t * instance, FILE * file,
 	bool_t stop_on_error);
 void clish_shell_insert_var(clish_shell_t *instance, clish_var_t *var);
 clish_var_t *clish_shell_find_var(clish_shell_t *instance, const char *name);
@@ -371,7 +325,7 @@ int clish_shell_wait(clish_shell_t * instance);
 int clish_shell_spawn_and_wait(clish_shell_t * instance,
 	const pthread_attr_t * attr);
 void clish_shell_load_scheme(clish_shell_t * instance, const char * xml_path);
-bool_t clish_shell_loop(clish_shell_t * instance);
+int clish_shell_loop(clish_shell_t * instance);
 clish_shell_state_t clish_shell__get_state(const clish_shell_t * instance);
 void clish_shell__set_state(clish_shell_t * instance,
 	clish_shell_state_t state);

+ 1 - 1
clish/shell/private.h

@@ -84,7 +84,7 @@ const clish_command_t *clish_shell_find_next_completion(const clish_shell_t *
  * BOOL_TRUE - the current file handle has been replaced.
  * BOOL_FALSE - there is only one handle on the stack which cannot be replaced.
  */
-bool_t clish_shell_pop_file(clish_shell_t * instance);
+int clish_shell_pop_file(clish_shell_t * instance);
 
 clish_view_t *clish_shell_find_view(clish_shell_t * instance, const char *name);
 void clish_shell_insert_view(clish_shell_t * instance, clish_view_t * view);

+ 27 - 28
clish/shell/shell_execute.c

@@ -40,7 +40,7 @@ static clish_shell_builtin_t clish_cmd_list[] = {
 
 /*----------------------------------------------------------- */
 /* Terminate the current shell session */
-static bool_t clish_close(clish_context_t *context, const lub_argv_t * argv)
+static int clish_close(clish_context_t *context, const lub_argv_t * argv)
 {
 	/* the exception proves the rule... */
 	clish_shell_t *this = (clish_shell_t *)context->shell;
@@ -48,7 +48,7 @@ static bool_t clish_close(clish_context_t *context, const lub_argv_t * argv)
 	argv = argv; /* not used */
 	this->state = SHELL_STATE_CLOSING;
 
-	return BOOL_TRUE;
+	return 0;
 }
 
 /*----------------------------------------------------------- */
@@ -57,10 +57,10 @@ static bool_t clish_close(clish_context_t *context, const lub_argv_t * argv)
  thread. Whether the script continues after command, but not script, 
  errors depends on the value of the stop_on_error flag.
 */
-static bool_t clish_source_internal(clish_context_t *context,
+static int clish_source_internal(clish_context_t *context,
 	const lub_argv_t * argv, bool_t stop_on_error)
 {
-	bool_t result = BOOL_FALSE;
+	int result = -1;
 	const char *filename = lub_argv__get_arg(argv, 0);
 	struct stat fileStat;
 
@@ -81,7 +81,7 @@ static bool_t clish_source_internal(clish_context_t *context,
 			stop_on_error);
 	}
 
-	return result;
+	return result ? -1 : 0;
 }
 
 /*----------------------------------------------------------- */
@@ -90,7 +90,7 @@ static bool_t clish_source_internal(clish_context_t *context,
  thread. Invoking a script in this way will cause the script to
  stop on the first error
 */
-static bool_t clish_source(clish_context_t *context, const lub_argv_t * argv)
+static int clish_source(clish_context_t *context, const lub_argv_t * argv)
 {
 	return (clish_source_internal(context, argv, BOOL_TRUE));
 }
@@ -101,7 +101,7 @@ static bool_t clish_source(clish_context_t *context, const lub_argv_t * argv)
  thread. Invoking a script in this way will cause the script to
  continue after command, but not script, errors.
 */
-static bool_t clish_source_nostop(clish_context_t *context, const lub_argv_t * argv)
+static int clish_source_nostop(clish_context_t *context, const lub_argv_t * argv)
 {
 	return (clish_source_internal(context, argv, BOOL_FALSE));
 }
@@ -110,19 +110,18 @@ static bool_t clish_source_nostop(clish_context_t *context, const lub_argv_t * a
 /*
  Show the shell overview
 */
-static bool_t
-clish_overview(clish_context_t *context, const lub_argv_t * argv)
+static int clish_overview(clish_context_t *context, const lub_argv_t * argv)
 {
 	clish_shell_t *this = context->shell;
 	argv = argv; /* not used */
 
 	tinyrl_printf(this->tinyrl, "%s\n", context->shell->overview);
 
-	return BOOL_TRUE;
+	return 0;
 }
 
 /*----------------------------------------------------------- */
-static bool_t clish_history(clish_context_t *context, const lub_argv_t * argv)
+static int clish_history(clish_context_t *context, const lub_argv_t * argv)
 {
 	clish_shell_t *this = context->shell;
 	tinyrl_history_t *history = tinyrl__get_history(this->tinyrl);
@@ -149,7 +148,7 @@ static bool_t clish_history(clish_context_t *context, const lub_argv_t * argv)
 			tinyrl_history_entry__get_index(entry),
 			tinyrl_history_entry__get_line(entry));
 	}
-	return BOOL_TRUE;
+	return 0;
 }
 
 /*----------------------------------------------------------- */
@@ -177,12 +176,12 @@ void clish_shell_cleanup_script(void *script)
 }
 
 /*----------------------------------------------------------- */
-bool_t clish_shell_execute(clish_context_t *context, char **out)
+int clish_shell_execute(clish_context_t *context, char **out)
 {
 	clish_shell_t *this = context->shell;
 	const clish_command_t *cmd = context->cmd;
 	clish_action_t *action;
-	bool_t result = BOOL_TRUE;
+	int result = 0;
 	char *lock_path = clish_shell__get_lockfile(this);
 	int lock_fd = -1;
 	sigset_t old_sigs;
@@ -213,7 +212,7 @@ bool_t clish_shell_execute(clish_context_t *context, char **out)
 		if (-1 == lock_fd) {
 			fprintf(stderr, "Can't open lockfile %s.\n",
 				lock_path);
-			return BOOL_FALSE; /* can't open file */
+			return -1; /* can't open file */
 		}
 		for (i = 0; i < CLISH_LOCK_WAIT; i++) {
 			res = flock(lock_fd, LOCK_EX | LOCK_NB);
@@ -232,7 +231,7 @@ bool_t clish_shell_execute(clish_context_t *context, char **out)
 		}
 		if (res) {
 			fprintf(stderr, "Can't get lock.\n");
-			return BOOL_FALSE; /* can't get the lock */
+			return -1; /* can't get the lock */
 		}
 	}
 
@@ -270,7 +269,7 @@ bool_t clish_shell_execute(clish_context_t *context, char **out)
 	}
 
 	/* Call config callback */
-	if (result && this->client_hooks->config_fn)
+	if (!result && this->client_hooks->config_fn)
 		this->client_hooks->config_fn(context);
 
 	/* Unlock the lockfile */
@@ -280,7 +279,7 @@ bool_t clish_shell_execute(clish_context_t *context, char **out)
 	}
 
 	/* Move into the new view */
-	if (result) {
+	if (!result) {
 		clish_view_t *view = clish_command__get_view(cmd);
 		/* Save the PWD */
 		if (view) {
@@ -295,11 +294,11 @@ bool_t clish_shell_execute(clish_context_t *context, char **out)
 }
 
 /*----------------------------------------------------------- */
-bool_t clish_shell_exec_action(clish_action_t *action,
+int clish_shell_exec_action(clish_action_t *action,
 	clish_context_t *context, char **out)
 {
 	clish_shell_t *this = context->shell;
-	bool_t result = BOOL_TRUE;
+	int result = 0;
 	const char *builtin;
 	char *script;
 
@@ -308,7 +307,7 @@ bool_t clish_shell_exec_action(clish_action_t *action,
 	if (builtin) {
 		clish_shell_builtin_fn_t *callback;
 		lub_argv_t *argv = script ? lub_argv_new(script, 0) : NULL;
-		result = BOOL_FALSE;
+		result = -1;
 		/* search for an internal command */
 		callback = find_builtin_callback(clish_cmd_list, builtin);
 		if (!callback) {
@@ -334,36 +333,36 @@ bool_t clish_shell_exec_action(clish_action_t *action,
 /*
  * Find out the previous view in the stack and go to it
  */
-static bool_t clish_nested_up(clish_context_t *context, const lub_argv_t * argv)
+static int clish_nested_up(clish_context_t *context, const lub_argv_t * argv)
 {
 	clish_shell_t *this = context->shell;
 
 	if (!this)
-		return BOOL_FALSE;
+		return -1;
 
 	argv = argv; /* not used */
 
 	/* If depth=0 than exit */
 	if (0 == this->depth) {
 		this->state = SHELL_STATE_CLOSING;
-		return BOOL_TRUE;
+		return 0;
 	}
 	this->depth--;
 
-	return BOOL_TRUE;
+	return 0;
 }
 
 /*----------------------------------------------------------- */
 /*
  * Builtin: NOP function
  */
-static bool_t clish_nop(clish_context_t *context, const lub_argv_t * argv)
+static int clish_nop(clish_context_t *context, const lub_argv_t * argv)
 {
-	return BOOL_TRUE;
+	return 0;
 }
 
 /*----------------------------------------------------------- */
-const char * clish_shell__get_fifo(clish_shell_t * this)
+const char *clish_shell__get_fifo(clish_shell_t * this)
 {
 	char *name;
 	int res;

+ 34 - 38
clish/shell/shell_file.c

@@ -4,74 +4,70 @@
 #include "private.h"
 
 /*----------------------------------------------------------- */
-bool_t clish_shell_push_file(clish_shell_t * this, const char * fname,
+int clish_shell_push_file(clish_shell_t * this, const char * fname,
 	bool_t stop_on_error)
 {
 	FILE *file;
-	bool_t res;
+	int res;
 
 	assert(this);
 	if (!fname)
-		return BOOL_FALSE;
+		return -1;
 	file = fopen(fname, "r");
 	if (!file)
-		return BOOL_FALSE;
+		return -1;
 	res = clish_shell_push_fd(this, file, stop_on_error);
-	if (!res)
+	if (res)
 		fclose(file);
 
 	return res;
 }
 
 /*----------------------------------------------------------- */
-bool_t clish_shell_push_fd(clish_shell_t * this, FILE * file,
+int clish_shell_push_fd(clish_shell_t * this, FILE * file,
 	bool_t stop_on_error)
 {
-	assert(this);
-
-	/* allocate a control node */
+	/* Allocate a control node */
 	clish_shell_file_t *node = malloc(sizeof(clish_shell_file_t));
-	bool_t result = BOOL_TRUE;
 
-	if (node) {
-		/* intialise the node */
-		node->file = file;
-		node->stop_on_error = stop_on_error;
-		node->next = this->current_file;
+	assert(this);
+	assert(node);
 
-		/* put the node at the top of the file stack */
-		this->current_file = node;
+	/* intialise the node */
+	node->file = file;
+	node->stop_on_error = stop_on_error;
+	node->next = this->current_file;
 
-		/* now switch the terminal's input stream */
-		tinyrl__set_istream(this->tinyrl, file);
+	/* put the node at the top of the file stack */
+	this->current_file = node;
 
-		result = BOOL_TRUE;
-	}
-	return result;
+	/* now switch the terminal's input stream */
+	tinyrl__set_istream(this->tinyrl, file);
+
+	return 0;
 }
 
 /*----------------------------------------------------------- */
-bool_t clish_shell_pop_file(clish_shell_t * this)
+int clish_shell_pop_file(clish_shell_t *this)
 {
-	bool_t result = BOOL_FALSE;
+	int result = -1;
 	clish_shell_file_t *node = this->current_file;
 
-	if (node) {
-		/* remove the current file from the stack... */
-		this->current_file = node->next;
-
-		/* and close the current file...
-		 */
-		fclose(node->file);
+	if (!node)
+		return -1;
 
-		if (node->next) {
-			/* now switch the terminal's input stream */
-			tinyrl__set_istream(this->tinyrl, node->next->file);
-			result = BOOL_TRUE;
-		}
-		/* and free up the memory */
-		free(node);
+	/* remove the current file from the stack... */
+	this->current_file = node->next;
+	/* and close the current file... */
+	fclose(node->file);
+	if (node->next) {
+		/* now switch the terminal's input stream */
+		tinyrl__set_istream(this->tinyrl, node->next->file);
+		result = 0;
 	}
+	/* and free up the memory */
+	free(node);
+
 	return result;
 }
 

+ 1 - 1
clish/shell/shell_new.c

@@ -116,7 +116,7 @@ static void clish_shell_fini(clish_shell_t * this)
 	if (this->startup)
 		clish_command_delete(this->startup);
 	/* clean up the file stack */
-	while (BOOL_TRUE == clish_shell_pop_file(this));
+	while (!clish_shell_pop_file(this));
 	/* delete the tinyrl object */
 	clish_shell_tinyrl_delete(this->tinyrl);
 

+ 23 - 20
clish/shell/shell_spawn.c

@@ -98,46 +98,46 @@ void clish_shell_load_scheme(clish_shell_t * this, const char *xml_path)
 }
 
 /*-------------------------------------------------------- */
-static bool_t _loop(clish_shell_t * this, bool_t is_thread)
+static int _loop(clish_shell_t * this, bool_t is_thread)
 {
-	bool_t running = BOOL_TRUE;
+	int running = 0;
 
 	assert(this);
 	if (!tinyrl__get_istream(this->tinyrl))
-		return BOOL_FALSE;
+		return -1;
 	/* Check the shell isn't closing down */
 	if (this && (SHELL_STATE_CLOSING == this->state))
-		return BOOL_TRUE;
+		return 0;
 
 	if (is_thread)
 		pthread_testcancel();
 	/* Loop reading and executing lines until the user quits */
-	while (running) {
+	while (!running) {
 		/* Get input from the stream */
 		running = clish_shell_readline(this, NULL);
-		if (!running) {
+		if (running) {
 			switch (this->state) {
 			case SHELL_STATE_SCRIPT_ERROR:
 			case SHELL_STATE_SYNTAX_ERROR:
 				/* Interactive session doesn't exit on error */
 				if (tinyrl__get_isatty(this->tinyrl) ||
 					!this->current_file->stop_on_error)
-					running = BOOL_TRUE;
+					running = 0;
 				break;
 			default:
 				break;
 			}
 		}
 		if (SHELL_STATE_CLOSING == this->state)
-			running = BOOL_FALSE;
-		if (!running)
+			running = -1;
+		if (running)
 			running = clish_shell_pop_file(this);
 		/* test for cancellation */
 		if (is_thread)
 			pthread_testcancel();
 	}
 
-	return BOOL_TRUE;
+	return 0;
 }
 
 /*-------------------------------------------------------- */
@@ -167,6 +167,8 @@ static void *clish_shell_thread(void *arg)
 {
 	clish_shell_t *this = arg;
 	int last_type;
+	int res = 0;
+	void *retval = 0;
 
 	/* make sure we can only be cancelled at controlled points */
 	pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &last_type);
@@ -174,17 +176,18 @@ static void *clish_shell_thread(void *arg)
 	pthread_cleanup_push((void (*)(void *))clish_shell_thread_cleanup, this);
 
 	if (this)
-		_loop(this, BOOL_TRUE);
+		res = _loop(this, BOOL_TRUE);
 
 	/* be a good pthread citizen */
 	pthread_cleanup_pop(1);
 
-	return (void *)BOOL_TRUE;
+	retval = res ? (void *)-1 : NULL;
+	return retval;
 }
 
 /*-------------------------------------------------------- */
-int clish_shell_spawn(clish_shell_t * this,
-	const pthread_attr_t * attr)
+int clish_shell_spawn(clish_shell_t *this,
+	const pthread_attr_t *attr)
 {
 	if (!this)
 		return -1;
@@ -194,20 +197,20 @@ int clish_shell_spawn(clish_shell_t * this,
 }
 
 /*-------------------------------------------------------- */
-int clish_shell_wait(clish_shell_t * this)
+int clish_shell_wait(clish_shell_t *this)
 {
 	void *result = NULL;
 
 	if (!this)
-		return BOOL_FALSE;
+		return -1;
 	(void)pthread_join(this->pthread, &result);
 
-	return result ? BOOL_TRUE : BOOL_FALSE;
+	return result ? -1 : 0;
 }
 
 /*-------------------------------------------------------- */
-int clish_shell_spawn_and_wait(clish_shell_t * this,
-	const pthread_attr_t * attr)
+int clish_shell_spawn_and_wait(clish_shell_t *this,
+	const pthread_attr_t *attr)
 {
 	if (clish_shell_spawn(this, attr) < 0)
 		return -1;
@@ -216,7 +219,7 @@ int clish_shell_spawn_and_wait(clish_shell_t * this,
 }
 
 /*-------------------------------------------------------- */
-bool_t clish_shell_loop(clish_shell_t * this)
+int clish_shell_loop(clish_shell_t *this)
 {
 	return _loop(this, BOOL_FALSE);
 }

+ 1 - 1
clish/shell/shell_startup.c

@@ -7,7 +7,7 @@
 #include "lub/string.h"
 
 /*----------------------------------------------------------- */
-bool_t clish_shell_startup(clish_shell_t *this)
+int clish_shell_startup(clish_shell_t *this)
 {
 	const char *banner;
 	clish_context_t context;

+ 12 - 11
clish/shell/shell_tinyrl.c

@@ -39,7 +39,7 @@ static bool_t clish_shell_tinyrl_key_help(tinyrl_t * this, int key)
 {
 	bool_t result = BOOL_TRUE;
 
-	if (BOOL_TRUE == tinyrl_is_quoting(this)) {
+	if (tinyrl_is_quoting(this)) {
 		/* if we are in the middle of a quote then simply enter a space */
 		result = tinyrl_insert_text(this, "?");
 	} else {
@@ -146,10 +146,10 @@ static bool_t clish_shell_tinyrl_key_space(tinyrl_t * this, int key)
 	const clish_command_t *cmd = NULL;
 	clish_pargv_t *pargv = NULL;
 
-	if(BOOL_TRUE == tinyrl_is_empty(this)) {
+	if(tinyrl_is_empty(this)) {
 		/* ignore space at the begining of the line, don't display commands */
 		return BOOL_TRUE;
-	} else if (BOOL_TRUE == tinyrl_is_quoting(this)) {
+	} else if (tinyrl_is_quoting(this)) {
 		/* if we are in the middle of a quote then simply enter a space */
 		result = BOOL_TRUE;
 	} else {
@@ -388,7 +388,7 @@ void clish_shell_tinyrl_delete(tinyrl_t * this)
 }
 
 /*-------------------------------------------------------- */
-bool_t clish_shell_execline(clish_shell_t *this, const char *line, char **out)
+int clish_shell_execline(clish_shell_t *this, const char *line, char **out)
 {
 	char *prompt = NULL;
 	const clish_view_t *view;
@@ -401,7 +401,7 @@ bool_t clish_shell_execline(clish_shell_t *this, const char *line, char **out)
 	this->state = SHELL_STATE_OK;
 	if (!line && !tinyrl__get_istream(this->tinyrl)) {
 		this->state = SHELL_STATE_SYSTEM_ERROR;
-		return BOOL_FALSE;
+		return -1;
 	}
 
 	/* Set up the context for tinyrl */
@@ -434,7 +434,7 @@ bool_t clish_shell_execline(clish_shell_t *this, const char *line, char **out)
 			this->state = SHELL_STATE_SYSTEM_ERROR;
 			break;
 		};
-		return BOOL_FALSE;
+		return -1;
 	}
 
 	/* Deal with the history list */
@@ -449,28 +449,29 @@ bool_t clish_shell_execline(clish_shell_t *this, const char *line, char **out)
 
 	/* Execute the provided command */
 	if (context.cmd && context.pargv) {
-		if (!clish_shell_execute(&context, out)) {
+		int res;
+		if ((res = clish_shell_execute(&context, out))) {
 			this->state = SHELL_STATE_SCRIPT_ERROR;
 			if (context.pargv)
 				clish_pargv_delete(context.pargv);
-			return BOOL_FALSE;
+			return res;
 		}
 	}
 
 	if (context.pargv)
 		clish_pargv_delete(context.pargv);
 
-	return BOOL_TRUE;
+	return 0;
 }
 
 /*-------------------------------------------------------- */
-bool_t clish_shell_forceline(clish_shell_t *this, const char *line, char ** out)
+int clish_shell_forceline(clish_shell_t *this, const char *line, char **out)
 {
 	return clish_shell_execline(this, line, out);
 }
 
 /*-------------------------------------------------------- */
-bool_t clish_shell_readline(clish_shell_t *this, char ** out)
+int clish_shell_readline(clish_shell_t *this, char **out)
 {
 	return clish_shell_execline(this, NULL, out);
 }