Re: [ILUG] BASH confusion

From: John Gaughan (jgaughan-ilug at domain irish-times.com)
Date: Tue 23 Oct 2001 - 13:40:29 IST


On Tue, 23 Oct 2001, Gavin McCullagh wrote:
> On Mon, 22 Oct 2001, Kevin O Riordan wrote:
> > Stick in a 'touch somenewfile', then log in again to see if the file
> > was created ...
> >
> > Best silliness yet:
> >
> > strace bash -login -c 'logout' 2>&1 | grep '^open'
>
> gavin at domain farfalle ~ % strace bash -login -c 'logout' 2>&1 | grep '^open'
> open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or
> directory)
> open("/etc/ld.so.cache", O_RDONLY) = 3
> open("/lib/libncurses.so.5", O_RDONLY) = 3
> open("/lib/libdl.so.2", O_RDONLY) = 3
> open("/lib/libc.so.6", O_RDONLY) = 3
> open("/dev/tty", O_RDWR|O_NONBLOCK|0x8000) = 3
> open("/etc/profile", O_RDONLY|0x8000) = 3
> open("/home/local/gavin/.bash_profile", O_RDONLY|0x8000) = 3
> open("/home/farfalle/gavin/.bashrc", O_RDONLY|0x8000) = 3
> open("/home/local/gavin/.bash_logout", O_RDONLY|0x8000) = -1 ENOENT (No
> such file or directory)
> open("/etc/bash.bash_logout", O_RDONLY|0x8000) = -1 ENOENT (No such file or
> directory)
>
> > That should show all the files bash sources on login ...

Not quite all, since your supplying a command to run (i.e., it's not an
interactive shell) the GNU readline library isn't used (readline
provides the command-line interface in bash, it's also used by other
programs such as ncftp and gdb). The readline startup files appear to
be read after bash's startup files, so they could be overriding the "set
-o emacs" in your bash startup files.

Readline is controlled by the files /etc/inputrc and ~/.inputrc. The
default key bindings are controlled by the "editing-mode" variable
(there's also a "keymap" variable, but as far as I can tell this
doesn't do anything). To set the key bindings to vi you'd add the line
"set editing-mode vi" to your .inputrc (or "set editing-mode emacs" for
emacs key bindings). You can see what your readline variables are set
to with "bind -V".

A neater way to see what files are read by bash when you login would be
to run an interactive session like this (and then logout from the new
shell that's started):

    strace -o bash.out -e trace=open bash -login

This will trace all open() calls and strace output is saved to the file
bash.out.

John.

-- 
John Gaughan, Systems Administrator
Irish Times New Media - http://www.ireland.com/


This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:12:52 GMT