diff --git a/src/subshell/common.c b/src/subshell/common.c
index 891d05f..03bcc6f 100644
a
|
b
|
static int subshell_ready; |
201 | 201 | /* Flag to indicate if the subshell supports the persistent buffer feature. */ |
202 | 202 | static gboolean use_persistent_buffer = FALSE; |
203 | 203 | |
204 | | /* Flag to indicate if the contents of the subshell command line need to be cleared before */ |
205 | | /* executing a command. This should only end up set to true if there is some sort of error. */ |
206 | | /* This allows us to recover gracefully from an error. */ |
207 | | static gboolean subshell_should_clear_command_line = FALSE; |
208 | | |
209 | 204 | /* This is the local variable where the subshell prompt is stored while we are working on it. */ |
210 | 205 | static GString *subshell_prompt_temp_buffer = NULL; |
211 | 206 | |
… |
… |
feed_subshell (int how, gboolean fail_on_error) |
752 | 747 | struct timeval *wptr; |
753 | 748 | |
754 | 749 | should_read_new_subshell_prompt = FALSE; |
755 | | subshell_should_clear_command_line = FALSE; |
756 | 750 | |
757 | | /* we wait up to 10 seconds if fail_on_error, forever otherwise */ |
758 | | wtime.tv_sec = 10; |
| 751 | /* we wait up to 1 second if fail_on_error, forever otherwise */ |
| 752 | wtime.tv_sec = 1; |
759 | 753 | wtime.tv_usec = 0; |
760 | 754 | wptr = fail_on_error ? &wtime : NULL; |
761 | 755 | |
… |
… |
feed_subshell (int how, gboolean fail_on_error) |
878 | 872 | if (subshell_ready && !read_command_line_buffer (FALSE)) |
879 | 873 | { |
880 | 874 | /* If we got here, some unforseen error must have occurred. */ |
| 875 | if (mc_global.shell->type != SHELL_FISH) |
| 876 | { |
| 877 | write_all (mc_global.tty.subshell_pty, "\003", 1); |
| 878 | subshell_state = RUNNING_COMMAND; |
| 879 | if (feed_subshell (QUIETLY, TRUE)) |
| 880 | { |
| 881 | if (read_command_line_buffer (FALSE)) |
| 882 | { |
| 883 | return TRUE; |
| 884 | } |
| 885 | } |
| 886 | } |
| 887 | subshell_state = ACTIVE; |
881 | 888 | flush_subshell (0, VISIBLY); |
882 | 889 | input_assign_text (cmdline, ""); |
883 | | subshell_should_clear_command_line = TRUE; |
884 | 890 | } |
885 | 891 | } |
886 | 892 | |
… |
… |
invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath) |
1455 | 1461 | /* data is there, but only if we are using one of the shells that */ |
1456 | 1462 | /* doesn't support keeping command buffer contents, OR if there was */ |
1457 | 1463 | /* some sort of error. */ |
1458 | | if (!use_persistent_buffer || subshell_should_clear_command_line) |
| 1464 | if (!use_persistent_buffer) |
1459 | 1465 | { |
1460 | | write_all (mc_global.tty.subshell_pty, "\003", 1); |
1461 | | subshell_state = RUNNING_COMMAND; |
1462 | | /* We need to call feed_subshell here if we are using fish, because of a quirk |
1463 | | * in the behavioral of that particular shell. */ |
| 1466 | /* We don't need to call feed_subshell here if we are using fish, because of a |
| 1467 | * quirk in the behavior of that particular shell. */ |
1464 | 1468 | if (mc_global.shell->type != SHELL_FISH) |
| 1469 | { |
| 1470 | write_all (mc_global.tty.subshell_pty, "\003", 1); |
| 1471 | subshell_state = RUNNING_COMMAND; |
1465 | 1472 | feed_subshell (QUIETLY, FALSE); |
| 1473 | } |
1466 | 1474 | } |
1467 | 1475 | |
1468 | 1476 | if (how == QUIETLY) |
… |
… |
do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) |
1667 | 1675 | |
1668 | 1676 | /* If we are using a shell that doesn't support persistent command buffer, we need to clear |
1669 | 1677 | * the command prompt before we send the cd command. */ |
1670 | | if (!use_persistent_buffer || subshell_should_clear_command_line) |
| 1678 | if (!use_persistent_buffer) |
1671 | 1679 | { |
1672 | 1680 | write_all (mc_global.tty.subshell_pty, "\003", 1); |
1673 | 1681 | subshell_state = RUNNING_COMMAND; |
1674 | 1682 | if (mc_global.shell->type != SHELL_FISH) |
1675 | | feed_subshell (QUIETLY, FALSE); |
| 1683 | { |
| 1684 | if (!feed_subshell (QUIETLY, TRUE)) |
| 1685 | { |
| 1686 | subshell_state = ACTIVE; |
| 1687 | return; |
| 1688 | } |
| 1689 | } |
1676 | 1690 | } |
1677 | 1691 | /* The initial space keeps this out of the command history (in bash |
1678 | 1692 | because we set "HISTCONTROL=ignorespace") */ |
… |
… |
do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) |
1703 | 1717 | write_all (mc_global.tty.subshell_pty, "\n", 1); |
1704 | 1718 | |
1705 | 1719 | subshell_state = RUNNING_COMMAND; |
1706 | | feed_subshell (QUIETLY, FALSE); |
| 1720 | if (!feed_subshell (QUIETLY, TRUE)) |
| 1721 | { |
| 1722 | subshell_state = ACTIVE; |
| 1723 | return; |
| 1724 | } |
1707 | 1725 | |
1708 | 1726 | if (subshell_alive) |
1709 | 1727 | { |
… |
… |
do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) |
1745 | 1763 | * type a space and press return. */ |
1746 | 1764 | write_all (mc_global.tty.subshell_pty, " \n", 2); |
1747 | 1765 | subshell_state = RUNNING_COMMAND; |
1748 | | feed_subshell (QUIETLY, FALSE); |
| 1766 | feed_subshell (QUIETLY, TRUE); |
1749 | 1767 | } |
1750 | 1768 | |
1751 | 1769 | update_subshell_prompt = FALSE; |