add a test_mode where the isatty() check is bypassed and history not read
this is enabled when the LAMMPS_SHELL_TESTING environment variable is set
This commit is contained in:
@ -531,16 +531,18 @@ static void init_commands()
|
|||||||
rl_readline_name = "lammps-shell";
|
rl_readline_name = "lammps-shell";
|
||||||
rl_basic_word_break_characters = " \t\n\"\\'`@><=;|&(";
|
rl_basic_word_break_characters = " \t\n\"\\'`@><=;|&(";
|
||||||
|
|
||||||
// attempt completions only if we are connected to a tty,
|
// attempt completions only if we are connected to a tty or are running tests.
|
||||||
// otherwise any tabs in redirected input will cause havoc.
|
// otherwise any tabs in redirected input will cause havoc.
|
||||||
if (isatty(fileno(stdin))) {
|
const char *test_mode = getenv("LAMMPS_SHELL_TESTING");
|
||||||
|
if (test_mode) std::cout << "*TESTING* using LAMMPS Shell in test mode *TESTING*\n";
|
||||||
|
if (isatty(fileno(stdin)) || test_mode) {
|
||||||
rl_attempted_completion_function = cmd_completion;
|
rl_attempted_completion_function = cmd_completion;
|
||||||
} else {
|
} else {
|
||||||
rl_bind_key('\t', rl_insert);
|
rl_bind_key('\t', rl_insert);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read old history
|
// read saved history, but not in test mode.
|
||||||
read_history(".lammps_history");
|
if (!test_mode) read_history(".lammps_history");
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
signal(SIGINT, ctrl_c_handler);
|
signal(SIGINT, ctrl_c_handler);
|
||||||
|
|||||||
Reference in New Issue
Block a user