Ticket #4198: cdfreeze.patch

File cdfreeze.patch, 5.0 KB (added by congest, 3 years ago)
  • src/subshell/common.c

    diff --git a/src/subshell/common.c b/src/subshell/common.c
    index 891d05f..03bcc6f 100644
    a b static int subshell_ready; 
    201201/* Flag to indicate if the subshell supports the persistent buffer feature. */ 
    202202static gboolean use_persistent_buffer = FALSE; 
    203203 
    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  
    209204/* This is the local variable where the subshell prompt is stored while we are working on it. */ 
    210205static GString *subshell_prompt_temp_buffer = NULL; 
    211206 
    feed_subshell (int how, gboolean fail_on_error) 
    752747    struct timeval *wptr; 
    753748 
    754749    should_read_new_subshell_prompt = FALSE; 
    755     subshell_should_clear_command_line = FALSE; 
    756750 
    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; 
    759753    wtime.tv_usec = 0; 
    760754    wptr = fail_on_error ? &wtime : NULL; 
    761755 
    feed_subshell (int how, gboolean fail_on_error) 
    878872                        if (subshell_ready && !read_command_line_buffer (FALSE)) 
    879873                        { 
    880874                            /* 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; 
    881888                            flush_subshell (0, VISIBLY); 
    882889                            input_assign_text (cmdline, ""); 
    883                             subshell_should_clear_command_line = TRUE; 
    884890                        } 
    885891                    } 
    886892 
    invoke_subshell (const char *command, int how, vfs_path_t ** new_dir_vpath) 
    14551461        /* data is there, but only if we are using one of the shells that */ 
    14561462        /* doesn't support keeping command buffer contents, OR if there was */ 
    14571463        /* some sort of error. */ 
    1458         if (!use_persistent_buffer || subshell_should_clear_command_line) 
     1464        if (!use_persistent_buffer) 
    14591465        { 
    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. */ 
    14641468            if (mc_global.shell->type != SHELL_FISH) 
     1469            { 
     1470                write_all (mc_global.tty.subshell_pty, "\003", 1); 
     1471                subshell_state = RUNNING_COMMAND; 
    14651472                feed_subshell (QUIETLY, FALSE); 
     1473            } 
    14661474        } 
    14671475 
    14681476        if (how == QUIETLY) 
    do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) 
    16671675 
    16681676    /* If we are using a shell that doesn't support persistent command buffer, we need to clear 
    16691677     * the command prompt before we send the cd command. */ 
    1670     if (!use_persistent_buffer || subshell_should_clear_command_line) 
     1678    if (!use_persistent_buffer) 
    16711679    { 
    16721680        write_all (mc_global.tty.subshell_pty, "\003", 1); 
    16731681        subshell_state = RUNNING_COMMAND; 
    16741682        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        } 
    16761690    } 
    16771691    /* The initial space keeps this out of the command history (in bash 
    16781692       because we set "HISTCONTROL=ignorespace") */ 
    do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) 
    17031717    write_all (mc_global.tty.subshell_pty, "\n", 1); 
    17041718 
    17051719    subshell_state = RUNNING_COMMAND; 
    1706     feed_subshell (QUIETLY, FALSE); 
     1720    if (!feed_subshell (QUIETLY, TRUE)) 
     1721    { 
     1722        subshell_state = ACTIVE; 
     1723        return; 
     1724    } 
    17071725 
    17081726    if (subshell_alive) 
    17091727    { 
    do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt) 
    17451763         * type a space and press return. */ 
    17461764        write_all (mc_global.tty.subshell_pty, " \n", 2); 
    17471765        subshell_state = RUNNING_COMMAND; 
    1748         feed_subshell (QUIETLY, FALSE); 
     1766        feed_subshell (QUIETLY, TRUE); 
    17491767    } 
    17501768 
    17511769    update_subshell_prompt = FALSE;