Make sure that line editing is disabled when the shell is not connected to a
tty.
This commit is contained in:
parent
43d9263589
commit
eaf9e4cff8
@ -200,7 +200,7 @@ preadfd(void)
|
|||||||
retry:
|
retry:
|
||||||
#ifndef NO_HISTORY
|
#ifndef NO_HISTORY
|
||||||
#ifdef EDITLINE
|
#ifdef EDITLINE
|
||||||
if (parsefile->fd == 0) {
|
if (parsefile->fd == 0 && editable) {
|
||||||
static const char *rl_cp= NULL;
|
static const char *rl_cp= NULL;
|
||||||
static size_t rl_off= 0;
|
static size_t rl_off= 0;
|
||||||
|
|
||||||
@ -561,5 +561,5 @@ closescript(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $PchId: input.c,v 1.6 2006/05/23 12:00:32 philip Exp $
|
* $PchId: input.c,v 1.7 2006/05/29 13:09:38 philip Exp $
|
||||||
*/
|
*/
|
||||||
|
@ -68,6 +68,7 @@ struct shparam shellparam; /* current positional parameters */
|
|||||||
char **argptr; /* argument list for builtin commands */
|
char **argptr; /* argument list for builtin commands */
|
||||||
char *shoptarg; /* set by nextopt (like getopt) */
|
char *shoptarg; /* set by nextopt (like getopt) */
|
||||||
char *optptr; /* used by nextopt */
|
char *optptr; /* used by nextopt */
|
||||||
|
int editable; /* isatty(0) && isatty(1) */
|
||||||
|
|
||||||
char *minusc; /* argument to -c option */
|
char *minusc; /* argument to -c option */
|
||||||
|
|
||||||
@ -96,7 +97,8 @@ procargs(int argc, char **argv)
|
|||||||
options(1);
|
options(1);
|
||||||
if (*argptr == NULL && minusc == NULL)
|
if (*argptr == NULL && minusc == NULL)
|
||||||
sflag = 1;
|
sflag = 1;
|
||||||
if (iflag == 2 && sflag == 1 && isatty(0) && isatty(1))
|
editable = (isatty(0) && isatty(1));
|
||||||
|
if (iflag == 2 && sflag == 1 && editable)
|
||||||
iflag = 1;
|
iflag = 1;
|
||||||
if (mflag == 2)
|
if (mflag == 2)
|
||||||
mflag = iflag;
|
mflag = iflag;
|
||||||
@ -540,5 +542,5 @@ nextopt(char *optstring)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $PchId: options.c,v 1.5 2006/05/22 12:23:10 philip Exp $
|
* $PchId: options.c,v 1.6 2006/05/29 13:09:12 philip Exp $
|
||||||
*/
|
*/
|
||||||
|
@ -103,6 +103,7 @@ extern struct shparam shellparam; /* $@ */
|
|||||||
extern char **argptr; /* argument list for builtin commands */
|
extern char **argptr; /* argument list for builtin commands */
|
||||||
extern char *shoptarg; /* set by nextopt */
|
extern char *shoptarg; /* set by nextopt */
|
||||||
extern char *optptr; /* used by nextopt */
|
extern char *optptr; /* used by nextopt */
|
||||||
|
extern int editable; /* isatty(0) && isatty(1) */
|
||||||
|
|
||||||
void procargs(int, char **);
|
void procargs(int, char **);
|
||||||
void optschanged(void);
|
void optschanged(void);
|
||||||
@ -115,5 +116,5 @@ int nextopt(char *);
|
|||||||
void getoptsreset(const char *);
|
void getoptsreset(const char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $PchId: options.h,v 1.4 2006/03/29 15:37:43 philip Exp $
|
* $PchId: options.h,v 1.5 2006/05/29 13:08:45 philip Exp $
|
||||||
*/
|
*/
|
||||||
|
@ -1555,12 +1555,14 @@ setprompt(int which)
|
|||||||
{
|
{
|
||||||
whichprompt = which;
|
whichprompt = which;
|
||||||
|
|
||||||
#ifndef EDITLINE
|
|
||||||
#ifndef NO_HISTORY
|
#ifndef NO_HISTORY
|
||||||
|
#ifdef EDITLINE
|
||||||
|
if (!editable)
|
||||||
|
#else
|
||||||
if (!el)
|
if (!el)
|
||||||
#endif
|
|
||||||
out2str(getprompt(NULL));
|
|
||||||
#endif /* EDITLINE */
|
#endif /* EDITLINE */
|
||||||
|
#endif /* !NO_HISTORY */
|
||||||
|
out2str(getprompt(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1672,5 +1674,5 @@ getprompt(void *unused __unused)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $PchId: parser.c,v 1.5 2006/05/22 12:27:09 philip Exp $
|
* $PchId: parser.c,v 1.6 2006/05/29 13:08:11 philip Exp $
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user