Compile bash 5.0 on Centos 7

 

 


bash 5.0 on Centos 7

wget https://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz
tar -zxf bash-5.0.tar.gz
cd bash-5.0
./configure --prefix=/opt/bash
CFLAGS="-march=x86-64 -O3 -pipe"
CXXFLAGS="${CFLAGS}"
export CFLAGS CXXFLAGS
make -j
make install

/opt/bash/bin/bash --version

 


更換系統的 bash

 

Script

build-loader.sh

#!/usr/bin/env bash
...

env could be considered "portable"

Using #!/usr/bin/env NAME makes the shell search for the first match of NAME in the $PATH environment variable.

echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

使用自行 compile 的 bash

export PATH=/opt/bash/bin:$PATH