From: Philip Homburg Date: Mon, 29 May 2006 13:20:28 +0000 (+0000) Subject: Make sure that line editing is disabled when the shell is not connected to a X-Git-Tag: v3.1.3~352 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/soc.html?a=commitdiff_plain;h=eaf9e4cff830defc25b8673667b8c17d145d3842;p=minix.git Make sure that line editing is disabled when the shell is not connected to a tty. --- diff --git a/commands/ash/input.c b/commands/ash/input.c index c44b4a87c..251232aa2 100755 --- a/commands/ash/input.c +++ b/commands/ash/input.c @@ -200,7 +200,7 @@ preadfd(void) retry: #ifndef NO_HISTORY #ifdef EDITLINE - if (parsefile->fd == 0) { + if (parsefile->fd == 0 && editable) { static const char *rl_cp= NULL; 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 $ */ diff --git a/commands/ash/options.c b/commands/ash/options.c index 6109f1a99..5b8706d03 100755 --- a/commands/ash/options.c +++ b/commands/ash/options.c @@ -68,6 +68,7 @@ struct shparam shellparam; /* current positional parameters */ char **argptr; /* argument list for builtin commands */ char *shoptarg; /* set by nextopt (like getopt) */ char *optptr; /* used by nextopt */ +int editable; /* isatty(0) && isatty(1) */ char *minusc; /* argument to -c option */ @@ -96,7 +97,8 @@ procargs(int argc, char **argv) options(1); if (*argptr == NULL && minusc == NULL) sflag = 1; - if (iflag == 2 && sflag == 1 && isatty(0) && isatty(1)) + editable = (isatty(0) && isatty(1)); + if (iflag == 2 && sflag == 1 && editable) iflag = 1; if (mflag == 2) 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 $ */ diff --git a/commands/ash/options.h b/commands/ash/options.h index 27b461a88..de1a55eba 100755 --- a/commands/ash/options.h +++ b/commands/ash/options.h @@ -103,6 +103,7 @@ extern struct shparam shellparam; /* $@ */ extern char **argptr; /* argument list for builtin commands */ extern char *shoptarg; /* set by nextopt */ extern char *optptr; /* used by nextopt */ +extern int editable; /* isatty(0) && isatty(1) */ void procargs(int, char **); void optschanged(void); @@ -115,5 +116,5 @@ int nextopt(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 $ */ diff --git a/commands/ash/parser.c b/commands/ash/parser.c index d837829ff..23375e4a7 100755 --- a/commands/ash/parser.c +++ b/commands/ash/parser.c @@ -1555,12 +1555,14 @@ setprompt(int which) { whichprompt = which; -#ifndef EDITLINE #ifndef NO_HISTORY +#ifdef EDITLINE + if (!editable) +#else if (!el) -#endif - out2str(getprompt(NULL)); #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 $ */