keep “set -x” disabled during PS4 expansion, to avoid infinite looping
This commit is contained in:
		
							
								
								
									
										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 -*- | ||||
| #- | ||||
| # 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 | ||||
|  | ||||
| expected-stdout: | ||||
| 	@(#)MIRBSD KSH R50 2015/02/20 | ||||
| 	@(#)MIRBSD KSH R50 2015/03/02 | ||||
| description: | ||||
| 	Check version of shell. | ||||
| stdin: | ||||
| @@ -39,7 +39,7 @@ name: KSH_VERSION | ||||
| category: shell:legacy-no | ||||
| --- | ||||
| expected-stdout: | ||||
| 	@(#)LEGACY KSH R50 2015/02/20 | ||||
| 	@(#)LEGACY KSH R50 2015/03/02 | ||||
| description: | ||||
| 	Check version of legacy shell. | ||||
| stdin: | ||||
| @@ -11930,3 +11930,26 @@ expected-stdout: | ||||
| 	Copyright (C) 2002 Free Software Foundation, Inc.' | ||||
| 	EOF | ||||
| 	chmod +x bash | ||||
| 	"$__progname" -xc 'foo=$(./bash --version 2>&1 | head -1); echo "=$foo="' | ||||
| expected-stdout: | ||||
| 	=GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)= | ||||
| 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) | ||||
|   | ||||
							
								
								
									
										14
									
								
								misc.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								misc.c
									
									
									
									
									
								
							| @@ -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; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /* | ||||
|   | ||||
							
								
								
									
										4
									
								
								sh.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								sh.h
									
									
									
									
									
								
							| @@ -169,9 +169,9 @@ | ||||
| #endif | ||||
|  | ||||
| #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 | ||||
| #define MKSH_VERSION "R50 2015/02/20" | ||||
| #define MKSH_VERSION "R50 2015/03/02" | ||||
|  | ||||
| /* arithmetic types: C implementation */ | ||||
| #if !HAVE_CAN_INTTYPES | ||||
|   | ||||
		Reference in New Issue
	
	Block a user