The Readline Library
In this lesson, you’ll learn about what readline is, what bash looks like without it, and how to manipulate and find out more about its features.
Readline is one of those technologies that is so commonly used people don’t realise it’s there. In this lesson I want to make you aware of it and introduce some concepts and examples of its use so you’re able to deal with any problems that arise from its use or misuse.
How Important is this Lesson?
Writing bash does not require a knowledge of readline. Understanding readline helps greatly to understand what is going on at the terminal and at the command line.
Bash Without Readline
First you’re going to see what bash looks like without readline.
In your ‘normal’ bash shell, hit the TAB
key twice. You should see
something like this:
Display all 2335 possibilities? (y or n)
That’s because bash normally has an autocomplete function that allows
you to see what commands are available to you if you tap TAB
twice.
Hit n
to get out of that autocomplete.
Similarly, if you hit the up arrow key a few times, then the previously-run commands should be brought back to the command line.
Now type:
bash --noediting
The --noediting
flag starts up bash without the readline library enabled.
If you hit tab twice now you will see something different: the shell no
longer ‘sees’ your tab and just sends a tab direct to the screen. Autocomplete
has gone.
Autocomplete is just one of the things that the readline library gives you in the terminal. You might want to try hitting the up or down arrows as you did above to see that that no longer works as well.
Hit return to get a fresh command line, and exit your non-readline-enabled bash shell:
exit