[Lib] Now try to call undefined command will cause a error code to return
This commit is contained in:
parent
a8158322ef
commit
3b7762ef85
|
@ -153,7 +153,7 @@ class Shell {
|
||||||
/* Show statistics of errors during command execution */
|
/* Show statistics of errors during command execution */
|
||||||
int execution_errors() const;
|
int execution_errors() const;
|
||||||
/* Quit the shell */
|
/* Quit the shell */
|
||||||
void exit() const;
|
void exit(const int& init_err = 0) const;
|
||||||
private: /* Private executors */
|
private: /* Private executors */
|
||||||
/* Execute a command, the command line is the user's input to launch a command
|
/* Execute a command, the command line is the user's input to launch a command
|
||||||
* The common_context is the data structure to exchange data between commands
|
* The common_context is the data structure to exchange data between commands
|
||||||
|
|
|
@ -363,8 +363,12 @@ void Shell<T>::run_script_mode(const char* script_file_name,
|
||||||
*/
|
*/
|
||||||
if (CMD_EXEC_FATAL_ERROR == status) {
|
if (CMD_EXEC_FATAL_ERROR == status) {
|
||||||
VTR_LOG("Fatal error occurred!\n");
|
VTR_LOG("Fatal error occurred!\n");
|
||||||
/* If not in the batch mode, we will got to interactive mode */
|
/* If in the batch mode, we will exit with errors */
|
||||||
VTR_LOGV(batch_mode, "OpenFPGA Abort\n");
|
VTR_LOGV(batch_mode, "OpenFPGA Abort\n");
|
||||||
|
if (batch_mode) {
|
||||||
|
exit(CMD_EXEC_FATAL_ERROR);
|
||||||
|
}
|
||||||
|
/* If not in the batch mode, we will got to interactive mode */
|
||||||
VTR_LOGV(!batch_mode, "Enter interactive mode\n");
|
VTR_LOGV(!batch_mode, "Enter interactive mode\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -438,15 +442,15 @@ int Shell<T>::execution_errors() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void Shell<T>::exit() const {
|
void Shell<T>::exit(const int& init_err) const {
|
||||||
/* Check all the command status, if we see fatal errors or minor errors, we drop an error code */
|
/* Check all the command status, if we see fatal errors or minor errors, we drop an error code */
|
||||||
int shell_exit_code = exit_code();
|
int shell_exit_code = exit_code() | init_err;
|
||||||
|
|
||||||
/* Show error message if we detect any errors */
|
/* Show error message if we detect any errors */
|
||||||
int num_err = 0;
|
int num_err = init_err;
|
||||||
if (0 != shell_exit_code) {
|
if (CMD_EXEC_SUCCESS != shell_exit_code) {
|
||||||
VTR_LOG("\n");
|
VTR_LOG("\n");
|
||||||
num_err = execution_errors();
|
num_err += execution_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
VTR_LOG("\nFinish execution with %d errors\n",
|
VTR_LOG("\nFinish execution with %d errors\n",
|
||||||
|
|
Loading…
Reference in New Issue