mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Ticket #4171: fix usermenu and macro system() calls disrupting terminal.
(execute_menu_command): prepare terminal to run system() and restore after. (user_menu_cmd): fix comment. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
09e904bf3d
commit
8177cdd0f1
@ -559,8 +559,26 @@ execute_menu_command (const WEdit * edit_widget, const char *commands, gboolean
|
||||
|
||||
if (show_prompt)
|
||||
shell_execute (cmd, EXECUTE_HIDE);
|
||||
else if (system (cmd) == -1)
|
||||
message (D_ERROR, MSG_ERROR, "%s", _("Error calling program"));
|
||||
else
|
||||
{
|
||||
gboolean ok;
|
||||
|
||||
/* Prepare the terminal by setting its flag to the initial ones. This will cause \r
|
||||
* to work as expected, instead of being ignored. */
|
||||
tty_reset_shell_mode ();
|
||||
|
||||
ok = (system (cmd) != -1);
|
||||
|
||||
/* Restore terminal configuration. */
|
||||
tty_raw_mode ();
|
||||
|
||||
/* Redraw the original screen's contents. */
|
||||
tty_clear_screen ();
|
||||
repaint_screen ();
|
||||
|
||||
if (!ok)
|
||||
message (D_ERROR, MSG_ERROR, "%s", _("Error calling program"));
|
||||
}
|
||||
|
||||
g_free (cmd);
|
||||
}
|
||||
@ -1026,7 +1044,7 @@ user_menu_cmd (const WEdit * edit_widget, const char *menu_file, int selected_en
|
||||
switch (*p)
|
||||
{
|
||||
case '#':
|
||||
/* show prompt if first line of external script is #interactive */
|
||||
/* do not show prompt if first line of external script is #silent */
|
||||
if (selected_entry >= 0 && strncmp (p, "#silent", 7) == 0)
|
||||
interactive = FALSE;
|
||||
/* A commented menu entry */
|
||||
|
Loading…
Reference in New Issue
Block a user