keep “set -x” disabled during PS4 expansion, to avoid infinite looping
This commit is contained in:
parent
06045cf889
commit
707add559f
29
check.t
29
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.681 2015/02/20 07:14:26 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.682 2015/03/01 15:23:03 tg Exp $
|
||||||
# -*- mode: sh -*-
|
# -*- mode: sh -*-
|
||||||
#-
|
#-
|
||||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
@ -30,7 +30,7 @@
|
|||||||
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
|
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R50 2015/02/20
|
@(#)MIRBSD KSH R50 2015/03/02
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -39,7 +39,7 @@ name: KSH_VERSION
|
|||||||
category: shell:legacy-no
|
category: shell:legacy-no
|
||||||
---
|
---
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)LEGACY KSH R50 2015/02/20
|
@(#)LEGACY KSH R50 2015/03/02
|
||||||
description:
|
description:
|
||||||
Check version of legacy shell.
|
Check version of legacy shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -11930,3 +11930,26 @@ expected-stdout:
|
|||||||
expected-stderr-pattern:
|
expected-stderr-pattern:
|
||||||
/.*/
|
/.*/
|
||||||
---
|
---
|
||||||
|
name: xtrace-2
|
||||||
|
description:
|
||||||
|
Check that "set -x" is off during PS4 expansion
|
||||||
|
stdin:
|
||||||
|
f() {
|
||||||
|
print -n "(f1:$-)"
|
||||||
|
set -x
|
||||||
|
print -n "(f2:$-)"
|
||||||
|
}
|
||||||
|
PS4='[(p:$-)$(f)] '
|
||||||
|
print "(o0:$-)"
|
||||||
|
set -x -o inherit-xtrace
|
||||||
|
print "(o1:$-)"
|
||||||
|
set +x
|
||||||
|
print "(o2:$-)"
|
||||||
|
expected-stdout:
|
||||||
|
(o0:sh)
|
||||||
|
(o1:shx)
|
||||||
|
(o2:sh)
|
||||||
|
expected-stderr:
|
||||||
|
[(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)'
|
||||||
|
[(p:sh)(f1:sh)(f2:sh)] set +x
|
||||||
|
---
|
||||||
|
14
misc.c
14
misc.c
@ -30,7 +30,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#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
|
#define KSH_CHVT_FLAG
|
||||||
#ifdef MKSH_SMALL
|
#ifdef MKSH_SMALL
|
||||||
@ -304,6 +304,11 @@ change_flag(enum sh_flag f, int what, bool newset)
|
|||||||
void
|
void
|
||||||
change_xtrace(unsigned char newval, bool dosnapshot)
|
change_xtrace(unsigned char newval, bool dosnapshot)
|
||||||
{
|
{
|
||||||
|
static bool in_xtrace;
|
||||||
|
|
||||||
|
if (in_xtrace)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!dosnapshot && newval == Flag(FXTRACE))
|
if (!dosnapshot && newval == Flag(FXTRACE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -328,8 +333,13 @@ change_xtrace(unsigned char newval, bool dosnapshot)
|
|||||||
shl_xtrace->fd = 2;
|
shl_xtrace->fd = 2;
|
||||||
|
|
||||||
changed_xtrace:
|
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);
|
shf_puts(substitute(str_val(global("PS4")), 0), shl_xtrace);
|
||||||
|
Flag(FXTRACE) = 2;
|
||||||
|
in_xtrace = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
4
sh.h
4
sh.h
@ -169,9 +169,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.713 2015/02/20 07:14:30 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.714 2015/03/01 15:23:05 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R50 2015/02/20"
|
#define MKSH_VERSION "R50 2015/03/02"
|
||||||
|
|
||||||
/* arithmetic types: C implementation */
|
/* arithmetic types: C implementation */
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
|
Loading…
x
Reference in New Issue
Block a user