Cmd history is not displaying correctly

2023-02-19 Thread Mr. Dick Steel

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -O2 -flto=auto -ffat-lto-objects -fexceptions -g 
-grecord-gcc-switches -pipe -Wall -Werror=format-security 
-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS 
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong 
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic 
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
uname output: Linux fedora-desktop 6.1.11-100.fc36.x86_64 #1 SMP 
PREEMPT_DYNAMIC Thu Feb  9 20:36:30 UTC 2023 x86_64 x86_64 x86_64 
GNU/Linux

Machine Type: x86_64-redhat-linux-gnu

Bash Version: 5.2
Patch Level: 15
Release Status: release

Description:
When you scroll your command history, it will display part of the 
previous command

and append the previous->previous command after it.

Repeat-By:
WARNING: The following will REPLACE your
current .bash_history file! Take care.

1. Start you terminal and run this command:

echo "ls -la
ls -la
cd Coding/
ls
cd libdick/
valgrind --leak-check=full ./build/test
cd ..
cd rust/hostname-ip-address/
valgrind --leak-check=full ./target/debug/hostname-ip-address
cd
cp .bash_history .bash_history_backup
nvim .bash_history
exit" > .bash_history

2. Exit terminal
3. Restart terminal
4. Use up arrow to scroll cmd history up until you hit:
"$ valgrind --leak-check=full 
./target/debug/hostname-ip-address"

and press up arrow once more and you will get:
"$ valgrind -cd rust/hostname-ip-address"

Expected result:
"$ cd rust/hostname-ip-address/"

Now, if you start to delete what is on the prompt, you will end up 
with:

"$ valgrind -"



Re: Cmd history is not displaying correctly

2023-02-19 Thread Greg Wooledge
On Sun, Feb 19, 2023 at 03:05:24PM +0200, Mr. Dick Steel wrote:
> 4. Use up arrow to scroll cmd history up until you hit:
> "$ valgrind --leak-check=full ./target/debug/hostname-ip-address"
> and press up arrow once more and you will get:
> "$ valgrind -cd rust/hostname-ip-address"
> 
> Expected result:
> "$ cd rust/hostname-ip-address/"

This sounds like a PS1 (prompt) issue to me.  Do you have color escape
sequences, or other such things, in your PS1 variable?  If so, they have
to be isolated within \[ \] markers, so bash knows they don't cause
the cursor to move.

https://mywiki.wooledge.org/BashFAQ/053



Re: Cmd history is not displaying correctly

2023-02-19 Thread Mr. Dick Steel

On 19-02-2023 16:07, Greg Wooledge wrote:

On Sun, Feb 19, 2023 at 03:05:24PM +0200, Mr. Dick Steel wrote:

4. Use up arrow to scroll cmd history up until you hit:
"$ valgrind --leak-check=full 
./target/debug/hostname-ip-address"

and press up arrow once more and you will get:
"$ valgrind -cd rust/hostname-ip-address"

Expected result:
"$ cd rust/hostname-ip-address/"


This sounds like a PS1 (prompt) issue to me.  Do you have color escape
sequences, or other such things, in your PS1 variable?  If so, they 
have

to be isolated within \[ \] markers, so bash knows they don't cause
the cursor to move.

https://mywiki.wooledge.org/BashFAQ/053


You are absolutely correct!
I have this in my .bashrc:

export PS1="\e[1;32m[\u@\h \W]\$ \e[m"

Thanks!



Re: Cmd history is not displaying correctly

2023-02-19 Thread Martin D Kealey
I suspect the history file is corrupt; truncating a file while another
process has it open for writing can do strange things.

On Sun, 19 Feb 2023, 23:05 Mr. Dick Steel,  wrote:

>  WARNING: The following will REPLACE your
>  current .bash_history file! Take care.
>
>  1. Start you terminal and run this command:
>
>  echo "ls -la
>  ls -la
>  cd Coding/
>  ls
>  cd libdick/
>  valgrind --leak-check=full ./build/test
>  cd ..
>  cd rust/hostname-ip-address/
>  valgrind --leak-check=full ./target/debug/hostname-ip-address
>  cd
>  cp .bash_history .bash_history_backup
>  nvim .bash_history
>  exit" > .bash_history
>
>  2. Exit terminal
>

at this point, what is in the file? does « wc -l  .bash_history » report 13?

 3. Restart terminal
>  4. Use up arrow to scroll cmd history up until you hit:
>  "$ valgrind --leak-check=full
> ./target/debug/hostname-ip-address"
>  and press up arrow once more and you will get:
>  "$ valgrind -cd rust/hostname-ip-address"
>
>  Expected result:
>  "$ cd rust/hostname-ip-address/"
>
>  Now, if you start to delete what is on the prompt, you will end up
> with:
>  "$ valgrind -"
>
>


Re: Cmd history is not displaying correctly

2023-02-19 Thread Mr. Dick Steel

On 19-02-2023 16:21, Martin D Kealey wrote:



at this point, what is in the file? does « wc -l  .bash_history » 
report 13?




It reports:
13 .bash_history

If I disable PS1 coloring, everything works correctly.