/bin/sh vi mode command line editing and the period

no at spam at mgedv.net nospam at mgedv.net
Wed Aug 29 07:07:42 PDT 2007


>> i just do the following:
>>
>> clear
>> /bin/sh
>> EDITOR=vi
>> export EDITOR
>> set -o $EDITOR
>> echo 1
>> echo 2
>> echo 3
>> echo 4
>> <ESC-.>
>>
> I tested the command sequence you gave and the result was as you
> explained. What caught my attention, however, was that all the
> commands were builtin. I tested with non-builtin commands (eg.
> /bin/echo instead of echo) and ESC-. did nothing. In fact unless the
> last command was a builtin, ESC-. just repeated the last _editing_
> action.
> This is not a desired behaviour however IMO, to repeat the last
> command (if builtin) upon a ESC-. on an empty line.
> Please correct me if I'm wrong.


well, now i did this:
/bin/sh
EDITOR=vi
export EDITOR
set -o $EDITOR
echo 1 >>foo
echo 2 >>foo
cat foo >>foo1
cat foo1 >>foo
cat foo


with this result:
test# /bin/sh
test# EDITOR=vi
test# export EDITOR
test# set -o $EDITOR
test# echo 1 >>foo
test# echo 2 >>foo
test# cat foo >>foo1
test# cat foo1 >>foo
test# cat foo
1
2
1
2
test#
test# echo 2 >>foo
test# cat foo >>foo1
test# cat foo1 >>foo
test# cat foo
1
2
1
2
2
1
2
1
2
1
2
2
test#

i took care that foo and foo1 did not exist prior to testing!
but i'm still not sure whether i should file a PR or not.
my assumption and expectance for ESC-. would be:
(regardless whether the input line is empty or not)
- ignore the key completely
- execute the last executed command again (ignoring the content
in the input buffer)

still, it's risky, maybe the command should not get executed but
pasted into the commandline like with ESC-- (minus).
executing should also be fine - if it's just the last command and
not the whole history. this is not a feature - for me it seems to
be much more than senseless.



More information about the freebsd-questions mailing list