keep “set -x” disabled during PS4 expansion, to avoid infinite looping

This commit is contained in:
tg
2015-03-01 15:23:05 +00:00
parent 06045cf889
commit 707add559f
3 changed files with 40 additions and 7 deletions

14
misc.c
View File

@ -30,7 +30,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.224 2015/01/25 15:23:41 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.225 2015/03/01 15:23:04 tg Exp $");
#define KSH_CHVT_FLAG
#ifdef MKSH_SMALL
@ -304,6 +304,11 @@ change_flag(enum sh_flag f, int what, bool newset)
void
change_xtrace(unsigned char newval, bool dosnapshot)
{
static bool in_xtrace;
if (in_xtrace)
return;
if (!dosnapshot && newval == Flag(FXTRACE))
return;
@ -328,8 +333,13 @@ change_xtrace(unsigned char newval, bool dosnapshot)
shl_xtrace->fd = 2;
changed_xtrace:
if ((Flag(FXTRACE) = newval) == 2)
if ((Flag(FXTRACE) = newval) == 2) {
in_xtrace = true;
Flag(FXTRACE) = 0;
shf_puts(substitute(str_val(global("PS4")), 0), shl_xtrace);
Flag(FXTRACE) = 2;
in_xtrace = false;
}
}
/*