3

I am wondering if OSX is missing $READLINE_LINE and $READLINE_POINT variables in scripts? I have updated to bash 4.4 and from what I read it should be available. The function is called using bind -x which should populate these variables in the function call. However, when I do so, they show as empty strings.

testreadline() {
    echo $READLINE_LINE
    echo $READLINE_POINT
}
bind -x '"\t": testreadline'

When I type some command and press the [TAB] key, it prints 2 empty lines.

I should also mention that this works fine on my Linux VM, so I'm suspecting that there's something different with my Mac.

=========================================================================

EDIT:

The problem was when I updated to bash 4.4, I was still pointing my terminal to the old install of bash /bin/bash. homebrew installs bash to /usr/local/bin/bash so you will need to change your preferences/profile to point to that location.

Kelvin
  • 574
  • 3
  • 13
  • 1
    Shadowing the built-in `test` command is extremely ill-advised. – tripleee Sep 19 '16 at 05:51
  • It wasn't actually test I just named it that to make it easier to read and didn't realize it was already a thing. Changed it, but it doesn't work regardless. – Kelvin Sep 19 '16 at 05:53
  • 1
    Works for me on MAC using bash 4, maybe you are picking up 3.2? – cdarke Sep 19 '16 at 06:59
  • Interesting... If I do `bash -version` it says 4.4.0(1)-release, but `$BASH_VERSION` is still 3.2.57(1)-release, anyone know why? – Kelvin Sep 19 '16 at 06:59
  • What does it say when you enter `bash -c 'echo $BASH_VERSION'` (single quotes are important here)? – user1934428 Sep 19 '16 at 08:38
  • More than likely the logon version is still 3.2. Try `/bin/bash --version` and `$(which bash) --version`. All you need do is to type `bash` on the command line and try again. – cdarke Sep 19 '16 at 09:09
  • You can change the shell in the terminal windows via Terminal/Preferences/"Shells open with". This is probably preferable to changing the logon shell, see http://stackoverflow.com/questions/453236/how-to-set-my-default-shell-on-mac – cdarke Sep 19 '16 at 09:18

0 Answers0