mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	Add regress test for redirection in DEBUG trap action (re: 2a835a2d)
				
					
				
			Turns out the previous commit also fixed the bug that disables the DEBUG trap if a redirection is used in a DEBUG trap action -- in other words, that's the same bug. src/cmd/ksh93/tests/basic.sh: - Add test from the reproducer in the bug report. Makes progress on: https://github.com/ksh93/ksh/issues/155
This commit is contained in:
		
							parent
							
								
									2a835a2d8a
								
							
						
					
					
						commit
						e664b78f98
					
				
					 2 changed files with 15 additions and 1 deletions
				
			
		|  | @ -745,6 +745,20 @@ got=$(eval 'x=`for i in test; do case $i in test) true;; esac; done`' 2>&1) \ | |||
| || err_exit "case in a for loop inside a \`comsub\` caused syntax error (got $(printf %q "$got"))" | ||||
| 
 | ||||
| # ====== | ||||
| # Redirecting disabled the DEBUG trap | ||||
| # https://github.com/ksh93/ksh/issues/155 (#1) | ||||
| exp=$'LINENO: 4\nfoo\nLINENO: 5\nLINENO: 6\nbar\nLINENO: 7\nbaz' | ||||
| got=$({ "$SHELL" -c ' | ||||
| 	PATH=/dev/null | ||||
| 	trap "echo LINENO: \$LINENO >&1" DEBUG	# 3 | ||||
| 	echo foo				# 4 | ||||
| 	var=$(echo)				# 5 | ||||
| 	echo bar				# 6 | ||||
| 	echo baz				# 7 | ||||
| '; } 2>&1) | ||||
| ((!(e = $?))) && [[ $got == "$exp" ]] || err_exit 'Redirection in DEBUG trap corrupts the trap' \ | ||||
| 	"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))" | ||||
| 
 | ||||
| # The DEBUG trap crashed when re-trapping inside a subshell | ||||
| # https://github.com/ksh93/ksh/issues/155 (#2) | ||||
| exp=$'trap -- \': main\' EXIT\ntrap -- \': main\' ERR\ntrap -- \': main\' KEYBD\ntrap -- \': main\' DEBUG' | ||||
|  | @ -760,7 +774,6 @@ got=$({ "$SHELL" -c ' | |||
| ((!(e = $?))) && [[ $got == "$exp" ]] || err_exit 'Pseudosignal trap failed when re-trapping in subshell' \ | ||||
| 	"(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))" | ||||
| 
 | ||||
| # ====== | ||||
| # The DEBUG trap had side effects on the exit status | ||||
| # https://github.com/ksh93/ksh/issues/155 (#4) | ||||
| trap ':' DEBUG | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue