#!/bin/sh

tar -xf bash-4.4.18.tar.gz
cd bash-4.4.18

ln -snf libncursesw.a /usr/lib/libcurses.a

#compile fail
#ref: https://lists.gnu.org/archive/html/bug-bash/2012-03/msg00052.html
#config.log:
#configure:14569: checking to see if getenv can be redefined
#configure:14615: gcc -o conftest -g -O2 -Wno-parentheses -Wno-format-security   -static conftest.c  >&5
#conftest.c: In function 'main':
#conftest.c:360: warning: incompatible implicit declaration of built-in function 'exit'
#configure:14615: $? = 0
#configure:14615: ./conftest
#configure:14615: $? = 0
#configure:14626: result: yes

sed -i -e 's%bash_cv_getenv_redef=yes%bash_cv_getenv_redef=no%' configure

./configure --prefix=/usr --bindir=/bin --sbindir=/sbin --sysconfdir=/etc --localstatedir=/var --libdir=/lib --build=x86_64-pc-linux-gnu --with-curses --enable-alias --enable-job-control --enable-multibyte --enable-readline --without-installed-readline --without-bash-malloc --enable-history --enable-process-substitution --enable-cond-command --enable-brace-expansion --enable-arith-for-command --enable-array-variables --enable-static-link --disable-nls --disable-debugger

make
strip --strip-unneeded bash
sync

cp -a -f /usr/bin/bash /usr/bin/bashORIG
cp -a -f bash /usr/bin/
sync

echo '/usr/bin/bash installed. When exit and chroot in again, will have'
echo 'improved commandline editing.'

