[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: support /etc/inputrc as a system-wide fallback default ?
From: |
Mike Frysinger |
Subject: |
Re: support /etc/inputrc as a system-wide fallback default ? |
Date: |
Mon, 6 Feb 2006 20:35:35 -0500 |
User-agent: |
KMail/1.9.1 |
On Saturday 04 February 2006 18:35, Dmitry V. Levin wrote:
> On Sat, Feb 04, 2006 at 03:27:19PM -0500, Mike Frysinger wrote:
> > we've been using a patch in Gentoo for sometime which adds support
> > for /etc/inputrc as a fallback after $INPUTRC and ~/.inputrc ... i
> > couldnt seem to find anything in the archives where someone proposed this
> > be added to readline, but maybe i just missed it ?
>
> I believe this idea comes from Debian and is used also in other distros
> including ALT and Owl, see e.g.
> http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/bash/readline-5.1-de
>b-alt-inputrc.diff
attached patch is what we use in Gentoo along with some stuff i added from the
above patch
-mike
diff -Nurp readline-5.1.orig/bind.c readline-5.1/bind.c
--- readline-5.1.orig/bind.c 2005-10-14 11:04:27.000000000 -0400
+++ readline-5.1/bind.c 2006-02-06 19:45:04.000000000 -0500
@@ -791,6 +791,7 @@ rl_re_read_init_file (count, ignore)
1. the filename used for the previous call
2. the value of the shell variable `INPUTRC'
3. ~/.inputrc
+ 4. /etc/inputrc
If the file existed and could be opened and read, 0 is returned,
otherwise errno is returned. */
int
@@ -799,17 +800,19 @@ rl_read_init_file (filename)
{
/* Default the filename. */
if (filename == 0)
+ filename = last_readline_init_file;
+ if (filename == 0)
+ filename = sh_get_env_value ("INPUTRC");
+ if (filename == 0 || *filename == 0)
{
- filename = last_readline_init_file;
- if (filename == 0)
- filename = sh_get_env_value ("INPUTRC");
- if (filename == 0)
- filename = DEFAULT_INPUTRC;
+ /* If there's trouble reading DEFAULT_INPUTRC then fall back
+ * to the SYSTEM_INPUTRC. */
+ filename = DEFAULT_INPUTRC;
+ if (_rl_read_init_file (filename, 0) == 0)
+ return 0;
+ filename = SYSTEM_INPUTRC;
}
- if (*filename == 0)
- filename = DEFAULT_INPUTRC;
-
#if defined (__MSDOS__)
if (_rl_read_init_file (filename, 0) == 0)
return 0;
diff -Nurp readline-5.1.orig/doc/rluser.texi readline-5.1/doc/rluser.texi
--- readline-5.1.orig/doc/rluser.texi 2005-09-14 14:22:30.000000000 -0400
+++ readline-5.1/doc/rluser.texi 2006-02-06 18:57:28.000000000 -0500
@@ -336,7 +336,8 @@ file is taken from the value of the shel
@ifclear BashFeatures
file is taken from the value of the environment variable @env{INPUTRC}. If
@end ifclear
-that variable is unset, the default is @file{~/.inputrc}.
+that variable is unset, the default is @file{~/.inputrc}. If that file
+does not exist, the last default is @file{/etc/inputrc}.
When a program which uses the Readline library starts up, the
init file is read, and the key bindings are set.
diff -Nurp readline-5.1.orig/rlconf.h readline-5.1/rlconf.h
--- readline-5.1.orig/rlconf.h 2002-01-22 12:54:23.000000000 -0500
+++ readline-5.1/rlconf.h 2006-02-06 19:05:02.000000000 -0500
@@ -37,9 +37,12 @@
/* Ugly but working hack for binding prefix meta. */
#define PREFIX_META_HACK
-/* The final, last-ditch effort file name for an init file. */
+/* The second to last, user-specific init file. */
#define DEFAULT_INPUTRC "~/.inputrc"
+/* The last-ditch, system-wide init file. */
+#define SYSTEM_INPUTRC "/etc/inputrc"
+
/* If defined, expand tabs to spaces. */
#define DISPLAY_TABS