bug-bash
[Top][All Lists]
Advanced

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

edit-and-execute-command, history and PS1


From: Jure Oder
Subject: edit-and-execute-command, history and PS1
Date: Thu, 2 Jun 2016 17:28:11 +0200

Dear all,

I have noticed strange behaviour if my PS1 variable contains "the history number of this command" (\!). When the prompt returns after invoking the edit-and-execute-command (C-xC-e) the history number is not increased. If I then press return, the history number is increased by two (or more, depending on how many lines(?) I entered with the editor). Also, if I then list the history, I notice that both, the part that was entered in the line before invoking (C-xC-e) and the part actually executed, are listed in history. The history number shown in the prompt before invoking C-xC-e refers to the partially constructed line (or empty, if nothing was entered). The actual history number I have to use to rerun the command is one higher.

I assume this is not the intended behaviour.

Steps to reproduce (<C-xC-e> marks where the key combination is pressed):
$ env -i /bin/bash --norc --noprofile
bash-4.3$ echo $BASH_VERSION
4.3.42(1)-release
bash-4.3$ EDITOR=vim
bash-4.3$ PS1='\! > '
4 > ls |<C-xC-e>
ls | grep foo
4 >
6 > history
    1  echo $BASH_VERSION
    2  EDITOR=vim
    3  PS1='\! > '
    4  ls |
    5  ls | grep foo
    6  history
7 >

I get similar behaviour with 4.3.33(2)-release, and 3.2.51(1)-release.

Thank you for your time and your dedication!

Best regards,
Jure

reply via email to

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