Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/editor/editcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3218,6 +3218,10 @@ edit_ext_cmd (WEdit * edit)
char *exp, *tmp, *tmp_edit_temp_file;
int e;

char *stdin_str = g_strdup ("/dev/null");
off_t start_mark, end_mark;
int block_present_flag = 0;

exp =
input_dialog (_("Paste output of external command"),
_("Enter shell command(s):"), MC_HISTORY_EDIT_PASTE_EXTCMD, NULL,
Expand All @@ -3228,12 +3232,21 @@ edit_ext_cmd (WEdit * edit)
if (!exp)
return 1;

if (eval_marks (edit, &start_mark, &end_mark))
{
g_free (stdin_str);
stdin_str = mc_config_get_full_path (EDIT_BLOCK_FILE);
edit_save_block (edit, stdin_str, start_mark, end_mark);
block_present_flag = 1;
}

tmp_edit_temp_file = mc_config_get_full_path (EDIT_TEMP_FILE);
tmp = g_strconcat (exp, " > ", tmp_edit_temp_file, (char *) NULL);
tmp = g_strconcat ("< ", stdin_str, " ", exp, " > ", tmp_edit_temp_file, (char *) NULL);
g_free (tmp_edit_temp_file);
e = system (tmp);
g_free (tmp);
g_free (exp);
g_free (stdin_str);

if (e)
{
Expand All @@ -3242,6 +3255,11 @@ edit_ext_cmd (WEdit * edit)
}

edit->force |= REDRAW_COMPLETELY;
if (block_present_flag)
{
if (edit_block_delete_cmd (edit))
return 1;
}

{
vfs_path_t *tmp_vpath;
Expand Down