1

On my Arch Linux machine (5.2.15), history navigation with the arrow keys sees commands in ~/.bash_history that start with the # character.

On my Mac OS machine (bash 3.2.57), history navigation with the arrow keys does not see commands in ~/.bash_history that start with the # character.

The history builtin has the same behaviour: it sees those commands on the Arch machine, but not on OS X. Running history -r doesn't cause the commented commands to show up, though I can see them in ~/.bash_history.

What causes this difference in behaviour and how can I configure bash on Mac OS to behave like it does on Arch Linux (so I see commented history entries)?

Both machines have very similar bash configuration:

Mac OS:

$ shopt -p | grep hist shopt -s cmdhist shopt -s histappend shopt -u histreedit shopt -u histverify shopt -u lithist $ echo $HISTCONTROL ignorespace 

Arch:

$ shopt | grep hist cmdhist on histappend on histreedit off histverify off lithist off $ echo $HISTCONTROL ignorespace 
7
  • 2
    Long dead version of Bash is buggy, news at 11. Jokes aside, FWIW, I can repro on a centos:5 docker container, which has 3.2.25(1), but not on a centos:6 container, which has 4.1.2(2). I'm betting this was a bug fixed with 4.0 or 4.1. Commented Nov 21, 2023 at 12:03
  • 1
    What are the values of $HISTIGNORE on the two machines? Does one of them include #*? Commented Nov 21, 2023 at 12:56
  • @terdon: unset on both -- but HISTIGNORE is about saving in history, which both machines do. The problem is that the mac doesn't load commented commands from history. Commented Nov 22, 2023 at 18:59
  • I think @muru already answered the question, maybe add that as the answer muru? Commented Nov 22, 2023 at 18:59
  • OK. I just tried with HISTIGNORE="#*" and then ran #foo and pressing the UP button didn't bring it back. And it seems reasonable that it can't load something if it hasn't saved it. In any case, if it is indeed a bug in an old bash version, there's not much more to add. Commented Nov 22, 2023 at 19:05

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.