mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	Fix BUG_CASEEMPT: empty 'case' list was syntax error
'case x in esac' should be syntactically correct, but was an error: $ ksh -c 'case x in esac' ksh: syntax error at line 1: `case' unmatched Inserting a newline was a workaround: $ ksh -c $'case x in\nesac' (no output) The problem was that the 'esac' reserved word was not being recognised if it immediately followed the 'in' reserved word. src/cmd/ksh93/sh/lex.c: sh_lex(): - Do not turn off recognition of reserved words after 'in' if we're in a 'case' construct; only do this for 'for' and 'select'. src/cmd/ksh93/tests/case.sh: - Add seven regression test for correct recognition of 'esac'. Only two failed on ksh93. The rest is to catch future bugs. Fixes: https://github.com/ksh93/ksh/issues/177
This commit is contained in:
		
							parent
							
								
									29b11bba3a
								
							
						
					
					
						commit
						e37aa358bf
					
				
					 3 changed files with 15 additions and 1 deletions
				
			
		
							
								
								
									
										3
									
								
								NEWS
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								NEWS
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -5,6 +5,9 @@ Any uppercase BUG_* names are modernish shell bug IDs.
 | 
			
		|||
 | 
			
		||||
2021-02-15:
 | 
			
		||||
 | 
			
		||||
- Fixed a regression introduced by ksh93 (was not in ksh88): an empty 'case'
 | 
			
		||||
  list on a single line ('case x in esac') was a syntax error.
 | 
			
		||||
 | 
			
		||||
- Fixed a bug in the emacs built-in editor, introduced on 2020-09-17, that
 | 
			
		||||
  made the Meta-D and Meta-H keys delete single characters instead of words.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1503,7 +1503,7 @@ breakloop:
 | 
			
		|||
			}
 | 
			
		||||
			else
 | 
			
		||||
				lp->lex.skipword = 0;
 | 
			
		||||
			if(c==INSYM)
 | 
			
		||||
			if(c==INSYM && !lp->lex.incase)
 | 
			
		||||
				lp->lex.reservok = 0;
 | 
			
		||||
			else if(c==TIMESYM)
 | 
			
		||||
			{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,4 +84,15 @@ esac') != b ]] && err_exit 'bug in ;& at end of script'
 | 
			
		|||
x=$($SHELL -ec 'case a in a) echo 1; false; echo 2 ;& b) echo 3;; esac')
 | 
			
		||||
[[ $x == 1 ]] || err_exit 'set -e ignored on case fail through'
 | 
			
		||||
 | 
			
		||||
# ======
 | 
			
		||||
# An empty 'case' list was a syntax error: https://github.com/ksh93/ksh/issues/177
 | 
			
		||||
got=$(eval 'case x in esac' 2>&1) || err_exit "empty case list fails: got $(printf %q "$got")"
 | 
			
		||||
got=$(eval ': || for i in esac; do :; done' 2>&1) || err_exit "'for i in esac' fails: got $(printf %q "$got")"
 | 
			
		||||
got=$(eval ': || select i in esac; do :; done' 2>&1) || err_exit "'select i in esac' fails: got $(printf %q "$got")"
 | 
			
		||||
(eval 'case x in esac) foo;; esac') 2>/dev/null && err_exit "unquoted 'esac' keyword as first selector fails to fail"
 | 
			
		||||
(eval 'case x in y) bar;; esac) foo;; esac') 2>/dev/null && err_exit "unquoted 'esac' kwyword as nth selector fails to fail"
 | 
			
		||||
got=$(eval 'case x in e\sac) foo;; esac' 2>&1) || err_exit "quoted 'esac' pattern (1) fails: got $(printf %q "$got")"
 | 
			
		||||
got=$(eval 'case x in y) bar;; es\ac) foo;; esac' 2>&1) || err_exit "quoted 'esac' pattern (2) fails: got $(printf %q "$got")"
 | 
			
		||||
 | 
			
		||||
# ======
 | 
			
		||||
exit $((Errors<125?Errors:125))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue