Weird make/gmake error

When gmake'ing tools, I started to get strange errors like:
/bin/bash: complete: command not found
/bin/bash: /home/users/lcarmich/etc/bash_completion: line 220: syntax error near unexpected token `(('
What I forget is that I build my own newer bash version (3.x) to be able to use the shell completions (and many other features) and the system default is 2.x. Don't ask about that. But gmake grabs the shell first in your path (older bash in my case).

I found that you can grab different version parts from bash in the BASH_VERSINFO array. Well I only really care about major version and this is available in variable BASH_VERSINFO or array element 0 BASH_VERSINFO[0]

I updated my bashrc to check version then load completions:
if [ -r $BASH_COMPLETION -a $BASH_VERSINFO -ge 3 ]; then
. $BASH_COMPLETION
fi
For future reference you can get array elements in bash with ${VARNAME[INDEX]}. For example:
mnsdev11 (netcat-0.7.1)$ echo $BASH_VERSION
3.2.0(1)-release
mnsdev11 (netcat-0.7.1)$ echo $BASH_VERSINFO
3
mnsdev11 (netcat-0.7.1)$ echo ${BASH_VERSINFO[0]}
3
mnsdev11 (netcat-0.7.1)$ echo ${BASH_VERSINFO[1]}
2
mnsdev11 (netcat-0.7.1)$ echo ${BASH_VERSINFO[2]}
0
mnsdev11 (netcat-0.7.1)$ echo ${BASH_VERSINFO[3]}
1
mnsdev11 (netcat-0.7.1)$ echo ${BASH_VERSINFO[4]}
release
Done.

Comments

Popular posts from this blog

Changing Dancer::Plugin::Ajax's content type

BootstrapX clickover

2 ways to get SQLite to put dates into columns