bash-custom-action/bash-4.1-edit-parser-state.patch
2010-06-24 10:05:26 +00:00

47 lines
1.4 KiB
Diff

|On 3/30/10 2:36 AM, Clark J. Wang wrote:
|> Good news:
|>
|> I met this problem again a few minutes ago. Then I looked back to find out
|> what I was doing. After some investigation I could stably reproduce this
|> problem by following steps (tested with bash 3.1.17, 3.2.39 and 4.1.0):
|>
|> bash$ alias xx='echo 142857' ### Make sure there isn't an external cmd
|> named `xx'
|> bash$ export EDITOR=vi
|> bash$ set -o vi
|> bash$ ### Press ESC to get out of vi's INSERT mode
|> bash$ ### Press v to invoke vi to input a cmd like `ls', save and exit,
|> the `ls' cmd runs.
|> bash$ xx
|> -bash: xx: command not found
|> bash$ xx
|> 142857
|> bash$
|
|Thanks for the report. This was exactly what I needed. The fix will be
|in the next release of bash. I've attached a patch for the curious or
|impatient.
|
|Chet
|
*** bashline.c 2010-03-26 12:15:37.000000000 -0400
--- bashline.c 2010-03-30 23:25:22.000000000 -0400
***************
*** 864,867 ****
--- 864,868 ----
char *command, *metaval;
int r, cclc, rrs, metaflag;
+ sh_parser_state_t ps;
rrs = rl_readline_state;
***************
*** 898,902 ****
--- 899,905 ----
if (rl_deprep_term_function)
(*rl_deprep_term_function) ();
+ save_parser_state (&ps);
r = parse_and_execute (command, (editing_mode == VI_EDITING_MODE) ? "v" : "C-xC-e", SEVAL_NOHIST);
+ restore_parser_state (&ps);
if (rl_prep_term_function)
(*rl_prep_term_function) (metaflag);