3

This question is related to https://askubuntu.com/q/826288/295286 In my search online, I could find no mention of whether bash 3.2 comes with readline support. Thus, I would like to know, if there is a systematic way of finding out what libraries bash uses.

In the linked question , I used locate to search for readline.so ,but that approach seems a bit unreliable to me.

1 Answer 1

5

This is probably a duplicate (I recall it being answered). But:

  • bash bundles readline, and
  • will use the bundled version of readline unless
  • it is specially configured, and
  • the bundled version is statically linked, so
  • you are unlikely to see it as a shared library dependency of bash.

For example:

$ ldd /bin/bash
        linux-vdso.so.1 (0x00007ffeae9a5000)
        libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007fe9bc832000)
        libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fe9bc608000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe9bc403000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe9bc062000)
        /lib64/ld-linux-x86-64.so.2 (0x000055a30b725000)

On the other hand, the dependency in Debian/testing upon libncurses.so.5 is unnecessary (bash uses only the termcap interface which is provided by libtinfo.so.5).

If you want to see that bash uses readline, use nm -D (Linux...) to see the symbol table:

$ nm -D /bin/bash |grep readline
00000000006ffab0 B bash_readline_initialized
00000000006fce00 B current_readline_line
00000000006fcdf8 B current_readline_line_index
00000000006fce08 B current_readline_prompt
000000000046d600 T initialize_readline
0000000000475400 T pcomp_set_readline_variables
000000000046d360 T posix_readline_initialize
000000000049a450 T readline
0000000000499d30 T readline_internal_char
0000000000499300 T readline_internal_setup
0000000000499430 T readline_internal_teardown
00000000006f7910 D rl_gnu_readline_p
00000000006fca20 D rl_readline_name
00000000007003f8 B rl_readline_state
00000000006f7914 D rl_readline_version

The external symbols (essentially the same approach) show these entrypoints for the termcap interface:

             U tgetent 
             U tgetflag
             U tgetnum 
             U tgetstr
             U tgoto  
             U tputs

(some people become confused by the libncurses dependency and suppose that bash uses ncurses — termcap applications are a special case).

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.