On 06/11/2014 07:26 PM, Chet Ramey wrote:
On 6/11/14, 6:35 AM, Ondrej Oprala wrote:
Hi,
bash-4.3 seems to act differently(better) in vi visual mode, than previous
bash-4 minors.
However, ksh gave a different result all along.
This isn't standardized, so I'm not worried about small differences between
implementations in something that happens interactively.
True, it's an unimportant detail, though ksh-compliance seems to
always be desired.
Anyway, one of my colleagues wrote a small patch that brings
the behaviour very close to ksh. Could you please comment on it?
Bash uses the `v' option to echo commands as they are read from the temp
file and executed, and that option is inherited by subshells. ksh93
doesn't seem to echo any commands at all. I personally think the bash
behavior is more useful.
Chet
Thanks,
Ondrej
diff -up bash-4.1/parse.y.noecho bash-4.1/parse.y
--- bash-4.1/parse.y.noecho 2014-05-29 14:46:09.545543384 +0200
+++ bash-4.1/parse.y 2014-05-29 14:48:40.758626213 +0200
@@ -3778,6 +3778,8 @@ xparse_dolparen (base, string, indp, fla
save_parser_state (&ps);
save_input_line_state (&ls);
orig_eof_token = shell_eof_token;
+ /* avoid echoing every substitution again */
+ echo_input_at_read = 0;
/*(*/
parser_state |= PST_CMDSUBST|PST_EOFTOKEN; /* allow instant ')' */ /*(*/
diff -up bash-4.1/subst.c.noecho bash-4.1/subst.c
--- bash-4.1/subst.c.noecho 2014-05-29 16:04:35.802784549 +0200
+++ bash-4.1/subst.c 2014-05-29 16:08:25.021942676 +0200
@@ -7103,6 +7103,7 @@ param_expand (string, sindex, quoted, ex
WORD_LIST *list;
WORD_DESC *tdesc, *ret;
int tflag;
+ int old_echo_input;
zindex = *sindex;
c = string[++zindex];
@@ -7401,6 +7402,9 @@ arithsub:
}
comsub:
+ old_echo_input = echo_input_at_read;
+ /* avoid echoing every substitution again */
+ echo_input_at_read = 0;
if (pflags & PF_NOCOMSUB)
/* we need zindex+1 because string[zindex] == RPAREN */
temp1 = substring (string, *sindex, zindex+1);
@@ -7413,6 +7417,7 @@ comsub:
}
FREE (temp);
temp = temp1;
+ echo_input_at_read = old_echo_input;
break;
/* Do POSIX.2d9-style arithmetic substitution. This will probably go