make command() not trash the global source variable
removes local save/restore around it in two of three callers; the third one is in runtrap() which… probably *cough* ought to have danced the same…
This commit is contained in:
parent
3e8165b9cd
commit
d96229b205
22
histrap.c
22
histrap.c
@ -27,7 +27,7 @@
|
|||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.157 2016/07/25 00:04:43 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.158 2016/08/04 20:31:00 tg Exp $");
|
||||||
|
|
||||||
Trap sigtraps[ksh_NSIG + 1];
|
Trap sigtraps[ksh_NSIG + 1];
|
||||||
static struct sigaction Sigact_ign;
|
static struct sigaction Sigact_ign;
|
||||||
@ -308,16 +308,8 @@ c_fc(const char **wp)
|
|||||||
/* Ignore setstr errors here (arbitrary) */
|
/* Ignore setstr errors here (arbitrary) */
|
||||||
setstr(local("_", false), tf->tffn, KSH_RETURN_ERROR);
|
setstr(local("_", false), tf->tffn, KSH_RETURN_ERROR);
|
||||||
|
|
||||||
/* XXX: source should not get trashed by this.. */
|
if ((optc = command(editor ? editor : TFCEDIT_dollaru, 0)))
|
||||||
{
|
return (optc);
|
||||||
Source *sold = source;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = command(editor ? editor : TFCEDIT_dollaru, 0);
|
|
||||||
source = sold;
|
|
||||||
if (ret)
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
struct stat statb;
|
struct stat statb;
|
||||||
@ -363,8 +355,6 @@ static int
|
|||||||
hist_execute(char *cmd, Area *areap)
|
hist_execute(char *cmd, Area *areap)
|
||||||
{
|
{
|
||||||
static int last_line = -1;
|
static int last_line = -1;
|
||||||
Source *sold;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Back up over last histsave */
|
/* Back up over last histsave */
|
||||||
if (histptr >= history && last_line != hist_source->line) {
|
if (histptr >= history && last_line != hist_source->line) {
|
||||||
@ -388,11 +378,7 @@ hist_execute(char *cmd, Area *areap)
|
|||||||
* X=y fc -e - 42 2> /dev/null
|
* X=y fc -e - 42 2> /dev/null
|
||||||
* are to effect the repeated commands environment.
|
* are to effect the repeated commands environment.
|
||||||
*/
|
*/
|
||||||
/* XXX: source should not get trashed by this.. */
|
return (command(cmd, 0));
|
||||||
sold = source;
|
|
||||||
ret = command(cmd, 0);
|
|
||||||
source = sold;
|
|
||||||
return (ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
9
main.c
9
main.c
@ -34,7 +34,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.314 2016/07/25 21:05:22 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.315 2016/08/04 20:31:01 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -734,12 +734,15 @@ include(const char *name, int argc, const char **argv, bool intr_ok)
|
|||||||
int
|
int
|
||||||
command(const char *comm, int line)
|
command(const char *comm, int line)
|
||||||
{
|
{
|
||||||
Source *s;
|
Source *s, *sold = source;
|
||||||
|
int rv;
|
||||||
|
|
||||||
s = pushs(SSTRING, ATEMP);
|
s = pushs(SSTRING, ATEMP);
|
||||||
s->start = s->str = comm;
|
s->start = s->str = comm;
|
||||||
s->line = line;
|
s->line = line;
|
||||||
return (shell(s, false));
|
rv = shell(s, false);
|
||||||
|
source = sold;
|
||||||
|
return (rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user