1
$ history
...
  242  yum whatprovides */bin/xdotool
  243  yum provides */bin/xdotool
  244  yum provides xdotool
  245  yum whatprovides xdotool
  246  yum whatprovides xdotool

At the prompt:

up

[root@localhost Downloads]# yum whatprovides xdotool

up

[root@localhost Downloads]# yum whatprovidesxdotool

up

[root@localhost Downloads]# yumtprovidesxdotool

up

[root@localhost Downloads]# yumtprovides*/bin/xdotool

up

[root@localhost Downloads]# yumwhattprovides*/bin/xdotool

Note that in the first recalled command there is a non-printable character which I am representing with (unicode box character) which is invisible in my terminal and does not take up a character space. In my terminal I see this:

yum whatprovides xdotool

NOT this:

yum whatprovides ☐xdotool

Using cat -A:

$ history | cat -A
...
 246  yum whatprovides M-BM-^Vxdotool $

I am running Cygwin mintty on Windows 10 with a shell connection to Fedora 29.

I am using system defaults.

$ echo $PS1
[\u@\h \W]\$

I think this is related to:

https://unix.stackexchange.com/a/31643/81989

When it's in PS1, bash counts the number of characters that get printed so that it can correctly redraw when you scroll through your history. That's why bash has the [ and ] special characters—they tell bash that the enclosed characters are not printable, which helps bash figure out how to redraw the prompt when necessary.

I believe that this non-printable character in my history that is what's causing it to bug out.

I am interested in understanding HOW and WHY this happened but I also want to know:

  • What options are available or recovery without purging my history
  • Can Bash be configured to discard these characters from the command history to avoid this from happening in the future?
  • Is there a way to identify what the offending character is?

As an aside, what are the use cases where preserving these non-printable characters in the command history is advantageous? Whenever I encounter this problem it's always a nuisance.

3
  • possibly this would be of interest? unix.stackexchange.com/questions/41739/…
    – Bart
    Commented Aug 15, 2019 at 10:23
  • This seems very similar to your other question ...?
    – Jeff Schaller
    Commented Aug 15, 2019 at 11:02
  • @JeffSchaller This question is specifically about Bash's command history and how to recover from this state. The other question is on how to avoid non-printable characters from being entered at the prompt to avoid reaching this state. I felt that they were unique enough to be split into separate questions.
    – Zhro
    Commented Aug 15, 2019 at 11:11

0

You must log in to answer this question.

Browse other questions tagged .