6.38. Readline-6.3

The Readline package is a set of libraries that offers command-line editing and history capabilities.

Approximate build time: 0.1 SBU
Required disk space: 24 MB

6.38.1. Installation of Readline

First install some patches to fix various bugs that have been addressed upstream:

patch -Np1 -i ../readline-6.3-upstream_fixes-3.patch

Reinstalling Readline will cause the old libraries to be moved to <libraryname>.old. While this is normally not a problem, in some cases it can trigger a linking bug in ldconfig. This can be avoided by issuing the following two seds:

sed -i '/MV.*old/d' Makefile.in
sed -i '/{OLDSUFF}/c:' support/shlib-install

Prepare Readline for compilation:

./configure --prefix=/usr    \
            --disable-static \
            --docdir=/usr/share/doc/readline-6.3

Compile the package:

make SHLIB_LIBS=-lncurses

The meaning of the make option:

SHLIB_LIBS=-lncurses

This option forces Readline to link against the libncurses (really, libncursesw) library.

This package does not come with a test suite.

Install the package to a temporary directory:

make SHLIB_LIBS=-lncurses DESTDIR=$(pwd)/debian/tmp install

Now move the dynamic libraries to a more appropriate location and fix up some symbolic links:

mkdir -pv debian/tmp/lib
mv -v debian/tmp/usr/lib/lib{readline,history}.so.* debian/tmp/lib
ln -sfv ../../lib/$(readlink debian/tmp/usr/lib/libreadline.so) \
        debian/tmp/usr/lib/libreadline.so
ln -sfv ../../lib/$(readlink debian/tmp/usr/lib/libhistory.so ) \
        debian/tmp/usr/lib/libhistory.so

If desired, install the documentation:

install -v -m644 doc/*.{ps,pdf,html,dvi} debian/tmp/usr/share/doc/readline-6.3

6.38.2. Creating the /etc/inputrc File

The inputrc file handles keyboard mapping for specific situations. This file is the startup file used by Readline.

Most people do not need user-specific keyboard mappings so the command below creates a global /etc/inputrc used by everyone who logs in. If you later decide you need to override the defaults on a per-user basis, you can create a .inputrc file in the user's home directory with the modified mappings.

For more information on how to edit the inputrc file, see info bash under the Readline Init File section. info readline is also a good source of information.

Below is a generic global inputrc along with comments to explain what the various options do. Note that comments cannot be on the same line as commands. Create the file using the following command:

mkdir -pv debian/tmp/etc
cat > debian/tmp/etc/inputrc << "EOF"
# Begin /etc/inputrc
# Modified by Chris Lynn <roryo@roryo.dynup.net>

# Allow the command prompt to wrap to the next line
set horizontal-scroll-mode Off

# Enable 8bit input
set meta-flag On
set input-meta On

# Turns off 8th bit stripping
set convert-meta Off

# Keep the 8th bit for display
set output-meta On

# none, visible or audible
set bell-style none

# All of the following map the escape sequence of the value
# contained in the 1st argument to the readline specific functions
"\eOd": backward-word
"\eOc": forward-word

# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for Konsole
"\e[H": beginning-of-line
"\e[F": end-of-line

# End /etc/inputrc
EOF

6.38.3. Finishing the Readline Installation

Create the package archive:

buildpkg

Install the package:

dpkg -i ../readline_6.3_*.deb

6.38.4. Contents of Readline

Installed libraries: libhistory.{a,so} and libreadline.{a,so}
Installed directories: /usr/include/readline, /usr/share/readline, and /usr/share/doc/readline-6.3

Short Descriptions

libhistory

Provides a consistent user interface for recalling lines of history

libreadline

Aids in the consistency of user interface across discrete programs that need to provide a command line interface