でも本日、心を入れ替えて bash-2.0.tar.gz をインストールします。
この bash 2.0 自身のコンパイルやインストールは、然程面倒ではな いです。ホントに極簡単にできます。
インストールする OS が Linux だと、十分に注意すべきです。理由は
だからです。例えば Linux の起動時に実行される rc ファイルはシェ ルスクリプトです。もし bash のバージョンを上げたことにより、この rc ファイルが実行できなくなったら、Linux を起動することさえでき なくなってしまうからです。
その辺もちゃんとふまえて、ではインストールしましょう。
まずは展開
cipher 505# ls -l bash-2.0.tar.gz -rw-r--r-- 1 yokota users 1349450 Dec 26 21:41 bash-2.0.tar.gz cipher 506# tar xfz bash-2.0.tar.gz cipher 507# cd bash-2.0 cipher 508# ls CHANGES bashline.c eval.c mailcheck.c sig.h COMPAT bashline.h examples mailcheck.h siglist.c COPYING bashtty.h execute_cmd.c make_cmd.c siglist.h CWRU bashtypes.h execute_cmd.h make_cmd.h stdc.h INSTALL bashwait.h expr.c maxpath.h stringlib.c MANIFEST bracecomp.c externs.h memalloc.h subst.c Makefile.in braces.c filecntl.h nojobs.c subst.h NEWS builtins flags.c oslib.c support NOTES builtins.h flags.h parse.y test.c README command.h general.c parser-built tests aclocal.m4 config.h.bot general.h parser.h trap.c alias.c config.h.in getcwd.c pathexp.c trap.h alias.h config.h.top hashlib.c pathexp.h unwind_prot.c ansi_stdlib.h configure hashlib.h pathnames.h unwind_prot.h array.c configure.in input.c posixdir.h variables.c array.h copy_cmd.c input.h posixstat.h variables.h bashansi.h dispose_cmd.c jobs.c print_cmd.c version.c bashhist.c dispose_cmd.h jobs.h quit.h vprint.c bashhist.h doc lib shell.c xmalloc.c bashintl.h error.c list.c shell.h y.tab.c bashjmp.h error.h locale.c sig.c y.tab.h次に configure をかけますが、環境に合わせてオプションを指定します。
私の場合は実行ファイルは /bin に、info は /usr/info に、 man は /usr/man に、そしてコンパイルのオプションは -O2 にしました。
cipher 509# CFLAGS=-O2 ./configure --bindir=/bin --infodir=/usr/info --mandir=/usr/manそしてコンパイルします。
cipher 511# make問題なく bash は作成されると思います。私はついでに strip もしちゃ いました。
cipher 512# file ./bash ./bash: ELF 32-bit LSB executable, Intel 386, version 1, not stripped cipher 513# strip ./bash cipher 514# file ./bash ./bash: ELF 32-bit LSB executable, Intel 386, version 1, stripped cipher 515# ls -l ./bash -rwxr-xr-x 1 yokota users 410460 Mar 5 18:17 ./bashうわぁ、ちょっとデカイんだぁ。
cipher 505# ldd bash libdl.so.1 => /lib/libdl.so.1.8.5 libc.so.5 => /lib/libc.so.5.4.13あれ、bash って termcap を使用しているハズなのに、なんで shared library じゃないんだろう。
と思ったら
cipher 506# ls -l /lib/libtermcap* lrwxrwxrwx 1 root root 19 Mar 5 19:35 /lib/libtermcap.so.2 -> libtermcap.so.2.0.0 -rwxr-xr-x 1 root root 11360 May 19 1995 /lib/libtermcap.so.2.0.0 cipher 507# ls -l /usr/lib/libtermcap* -rw-r--r-- 1 root root 8740 May 19 1995 /usr/lib/libtermcap.aいかぁん、symbolic link がない。
cipher 508# su Password: cipher:~# cipher:~# ln -s /lib/libtermcap.so.2.0.0 /usr/lib/libtermcap.so cipher:~# ls -l /usr/lib/libtermcap* -rw-r--r-- 1 root root 8740 May 19 1995 /usr/lib/libtermcap.a lrwxrwxrwx 1 root root 24 Mar 5 19:39 /usr/lib/libtermcap.so -> /lib/libtermcap.so.2.0.0これでよし。もう一度 bash を make だ。
cipher 511# rm bash cipher 512# make rm -f bash gcc -rdynamic -O2 -L./builtins -L./lib/readline -L./lib/readline -L./lib/tilde -L./lib/glob -L./lib/malloc -o bash shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o expr.o flags.o jobs.o subst.o hashlib.o mailcheck.o test.o trap.o input.o unwind_prot.o pathexp.o sig.o version.o alias.o array.o braces.o bracecomp.o bashhist.o bashline.o getcwd.o siglist.o vprint.o oslib.o list.o stringlib.o locale.o xmalloc.o -lbuiltins -lreadline -lhistory -ltermcap -lglob -ltilde -lmalloc -ldl ls -l bash -rwxr-xr-x 1 yokota users 484599 Mar 5 19:40 bash size bash text data bss dec hex filename 269640 130252 5816 405708 630cc bash cp .machine .made cipher 513# strip bash cipher 514# ls -l bash -rwxr-xr-x 1 yokota users 405532 Mar 5 19:40 bash cipher 515# ldd bash libtermcap.so.2 => /lib/libtermcap.so.2.0.0 libdl.so.1 => /lib/libdl.so.1.8.5 libc.so.5 => /lib/libc.so.5.4.13これでよし。termcap を shared library にしたって、たかが 5KB しか変わ らないけど、まぁいいや。インストールしよっと。
ただし、ここで必ず今迄の bash のバックアップを取っておくこと。私の環境 では今迄の bash のバージョンは 1.14.7 ですので、bash_1.14.7 と いう名前でバックアップを取っておくことにした。
cipher 516# su Password: cipher:~# ls -l /bin/bash -rwxr-xr-x 1 root root 305784 Nov 27 23:50 /bin/bash cipher:~# cp -a /bin/bash /bin/bash_1.14.7 cipher:~# ls -l /bin/bash /bin/bash_1.14.7 -rwxr-xr-x 1 root root 305784 Nov 27 23:50 /bin/bash -rwxr-xr-x 1 root root 305784 Nov 27 23:50 /bin/bash_1.14.7で実際にインストールをする。
cipher:~# make install cp .machine .made /usr/bin/ginstall -c bash /bin/bash /usr/bin/ginstall -c bashbug /bin/bashbug ( cd ./doc ; make \ man1dir=/usr/man/man1 man1ext=1 \ man3dir=/usr/man/man3 man3ext=3 \ infodir=/usr/info install ) make[1]: Entering directory `/home/yokota/next/bash-2.0/doc' test -d /usr/man/man1 || /bin/sh ../support/mkdirs /usr/man/man1 test -d /usr/man/man3 || /bin/sh ../support/mkdirs /usr/man/man3 test -d /usr/info || /bin/sh ../support/mkdirs /usr/info /usr/bin/ginstall -c -m 644 ./bash.1 /usr/man/man1/bash.1 /usr/bin/ginstall -c -m 644 ./bashbug.1 /usr/man/man1/bashbug.1 /usr/bin/ginstall -c -m 644 ./readline.3 /usr/man/man3/readline.3 /usr/bin/ginstall -c -m 644 ./bashref.info /usr/info/bash.info make[1]: Leaving directory `/home/yokota/next/bash-2.0/doc' cipher:~# ls -l /bin/bash /bin/bash_1.14.7 -rwxr-xr-x 1 root root 405532 Mar 5 19:50 /bin/bash -rwxr-xr-x 1 root root 305784 Nov 27 23:50 /bin/bash_1.14.7 cipher:~# ls -l /bin/sh lrwxrwxrwx 1 root root 4 Jul 27 1996 /bin/sh -> bashさて、最後に rc ファイルのチェックだ。必ずコレはすること。
さもないと後で泣くことになる。
cipher:~# cd /etc/rc.d/ cipher:~# ls rc.0 rc.M rc.diald rc.local rc.4 rc.S rc.inet1 rc.local.org rc.6 rc.S_old rc.inet2 rc.serial rc.K rc.cdrom.orig rc.keymap rc.serial.orig cipher:~# sh -n rc.0 cipher:~# sh -n rc.4 cipher:~# sh -n rc.6 cipher:~# sh -n rc.K cipher:~# sh -n rc.M cipher:~# sh -n rc.S cipher:~# sh -n rc.diald cipher:~# sh -n rc.inet1 cipher:~# sh -n rc.inet2 cipher:~# sh -n rc.keymap cipher:~# sh -n rc.local cipher:~# sh -n rc.serialこのオプション -n は実際には実行をしないで、syntax のチェックをするオ プションです。これで何もエラーが出てこなければ OK です。安心してこのま ま使用できます。
もし何かエラーが出てきたらファイルの中の記述が間違っています。正しく修 正しましょう。もしも修正のしかたが分らない場合は、残念ですが、bash を 元に戻しましょう。でないと二度と Linux が立ち上げられなくなります。
さて、何故これ程のチェックが必要かというと、ちょっとしたことなんですが syntax check が厳しくなっているからです。例えば
echo a1
function foo { echo FOO }
echo a2
foo
や
echo b1
bar () { echo BAR }
echo b2
bar
は、ホントは syntax error です。しかし 1.14.7 では問題なく動い
てしまっていました。ですがこれが 2.0.0 ではしっかりと syntax
error になってしまうのです。つまり今迄使えていたからといって
2.0.0 でも使えるとは限らないんです。実は ~/.bashrc にこんな記述があり、ちょっとハマったんです。いやぁ 情けない。:-)
みなさんも御気を付けて。
今日はルンルンのスィッチオフ。