From b642e2e1e1732d16103bb5d9694cdc9d4536449c Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Mon, 31 Jan 2011 22:08:15 +0000 Subject: [PATCH] added check for instruction "#interactive" in the script. if the external script contain #interactive then do show prompt. Signed-off-by: Ilia Maslakov Signed-off-by: Slava Zanko Signed-off-by: Andrew Borodin --- doc/man/mcedit.1.in | 5 ++++- src/filemanager/usermenu.c | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/doc/man/mcedit.1.in b/doc/man/mcedit.1.in index 11a607883..bb7d014fa 100644 --- a/doc/man/mcedit.1.in +++ b/doc/man/mcedit.1.in @@ -137,7 +137,10 @@ See .B Menu File Edit for more detail about format of the script. .PP -Next macro definition can be used: +Following macro definition and directives can be used: +.TP +.I #interactive +If this directive is set, then script starts in subshell. .TP .I %c The cursor column position number. diff --git a/src/filemanager/usermenu.c b/src/filemanager/usermenu.c index 36c404da6..c093776a9 100644 --- a/src/filemanager/usermenu.c +++ b/src/filemanager/usermenu.c @@ -404,7 +404,7 @@ test_line (WEdit * edit_widget, char *p, int *result) /** FIXME: recode this routine on version 3.0, it could be cleaner */ static void -execute_menu_command (WEdit * edit_widget, const char *commands, gboolean dont_show_prompt) +execute_menu_command (WEdit * edit_widget, const char *commands, gboolean show_prompt) { FILE *cmd_file; int cmd_file_fd; @@ -534,7 +534,7 @@ execute_menu_command (WEdit * edit_widget, const char *commands, gboolean dont_s /* execute the command indirectly to allow execution even * on no-exec filesystems. */ char *cmd = g_strconcat ("/bin/sh ", file_name, (char *) NULL); - if (dont_show_prompt) + if (!show_prompt) { if (system (cmd) == -1) message (D_ERROR, MSG_ERROR, "%s", _("Error calling program")); @@ -868,6 +868,7 @@ user_menu_cmd (struct WEdit *edit_widget, const char *menu_file, int selected_en int selected, old_patterns; Listbox *listbox; gboolean res = FALSE; + gboolean interactive = FALSE; if (!vfs_current_is_local ()) { @@ -954,6 +955,9 @@ user_menu_cmd (struct WEdit *edit_widget, const char *menu_file, int selected_en { if (*p == '#') { + /* show prompt if first line of external script is #interactive */ + if (selected_entry >= 0 && strncmp (p, "#interactive", 12) == 0) + interactive = TRUE; /* A commented menu entry */ accept_entry = 1; } @@ -1047,7 +1051,7 @@ user_menu_cmd (struct WEdit *edit_widget, const char *menu_file, int selected_en } if (selected >= 0) { - execute_menu_command (edit_widget, entries[selected], (selected_entry >= 0)); + execute_menu_command (edit_widget, entries[selected], interactive); res = TRUE; } -- 2.11.4.GIT