[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Echoing commands in vi visual mode

From: Filip Krska
Subject: Re: Echoing commands in vi visual mode
Date: Wed, 02 Jul 2014 11:22:10 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

Hi Chet,

On 06/30/2014 08:55 PM, Chet Ramey wrote:
On 6/26/14, 4:56 AM, Ondrej Oprala wrote:
On 06/11/2014 07:26 PM, Chet Ramey wrote:
On 6/11/14, 6:35 AM, Ondrej Oprala wrote:
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.
Not really.  There's no reason to be deliberately incompatible with other
shells where non-interactive features are concerned, but ksh is not
something to be `compliant' with.
Yep, I'd not suggest to take ksh always as an etalon of compliance ;).

However, if we are swimming in "undefined" waters, we can consider usability and "user expectation". And in this case, especially when substitution occurs in cycle, echoing substituted commands seems not only unexpected, but annoying (that's why it was reported to us). See:

If I enter in edit-and-execute-command (C-xC-e) e.g.

for i in $(seq 1 4);do    j=$(echo $i$i );    echo $j; done
echo second

it result for bash-4.3 in:

for i in $(seq 1 4);do j=$(echo $i$i ); echo $j; done
seq 1 4
echo $i$i
echo $i$i
echo $i$i
echo $i$i
echo second

However, with the proposed patch the output reads:

for i in $(seq 1 4);do    j=$(echo $i$i );    echo $j; done
echo second

Of course, treat the patch rather as proof of concept, there may be side effect I'm not aware.

Anyway, one of my colleagues wrote a small patch that brings
the behaviour very close to ksh. Could you please comment on it?
The interesting thing about this is that very few shells, other than
bash, seem to inherit the -v option in subshells.  This looks like a
place where Posix doesn't reflect historical behavior, since Posix says
that subshell environments inherit all options.  I guess it's a question
of when the command in the command substitution is `read'.


Thanks and Regards,


Filip Krška

GSS-SEG EMEA engineer, #sbr-shells (pri), #sbr-anaconda (sec)
Red Hat Czech s.r.o.
Purkyňova 99/71
612 45, Brno, Czech Republic
office phone:+420 5322 94499

♡ All Wrongs Reversed

reply via email to

[Prev in Thread] Current Thread [Next in Thread]