Make the default editrc file be $EDITRC (from env) if set, falling back
to $HOME/.editrc otherwise. Better support for this in sh coming.
This commit is contained in:
parent
a3be5e86c2
commit
4fa1b5993a
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: el.c,v 1.92 2016/05/22 19:44:26 christos Exp $ */
|
/* $NetBSD: el.c,v 1.93 2017/06/27 00:47:37 kre Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
|
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: el.c,v 1.92 2016/05/22 19:44:26 christos Exp $");
|
__RCSID("$NetBSD: el.c,v 1.93 2017/06/27 00:47:37 kre Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint && not SCCSID */
|
#endif /* not lint && not SCCSID */
|
||||||
|
|
||||||
|
@ -524,18 +524,22 @@ el_source(EditLine *el, const char *fname)
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
if (fname == NULL) {
|
if (fname == NULL) {
|
||||||
#ifdef HAVE_ISSETUGID
|
#ifdef HAVE_ISSETUGID
|
||||||
static const char elpath[] = "/.editrc";
|
|
||||||
size_t plen = sizeof(elpath);
|
|
||||||
|
|
||||||
if (issetugid())
|
if (issetugid())
|
||||||
return -1;
|
return -1;
|
||||||
if ((ptr = getenv("HOME")) == NULL)
|
|
||||||
return -1;
|
if ((fname = getenv("EDITRC")) == NULL) {
|
||||||
plen += strlen(ptr);
|
static const char elpath[] = "/.editrc";
|
||||||
if ((path = el_malloc(plen * sizeof(*path))) == NULL)
|
size_t plen = sizeof(elpath);
|
||||||
return -1;
|
|
||||||
(void)snprintf(path, plen, "%s%s", ptr, elpath);
|
if ((ptr = getenv("HOME")) == NULL)
|
||||||
fname = path;
|
return -1;
|
||||||
|
plen += strlen(ptr);
|
||||||
|
if ((path = el_malloc(plen * sizeof(*path))) == NULL)
|
||||||
|
return -1;
|
||||||
|
(void)snprintf(path, plen, "%s%s", ptr,
|
||||||
|
elpath + (*ptr == '\0'));
|
||||||
|
fname = path;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
* If issetugid() is missing, always return an error, in order
|
* If issetugid() is missing, always return an error, in order
|
||||||
|
@ -545,6 +549,9 @@ el_source(EditLine *el, const char *fname)
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
if (fname[0] == '\0')
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
fp = fopen(fname, "r");
|
fp = fopen(fname, "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue