mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	move exit/return tests from basic.sh to return.sh (re: 092b90da)
				
					
				
			This commit is contained in:
		
							parent
							
								
									21d00ffb6c
								
							
						
					
					
						commit
						0e9aaf1635
					
				
					 2 changed files with 70 additions and 66 deletions
				
			
		| 
						 | 
				
			
			@ -431,72 +431,6 @@ if	env x-a=y >/dev/null 2>&1
 | 
			
		|||
then	[[ $(env 'x-a=y'  $SHELL -c 'env | grep x-a') == *x-a=y* ]] || err_exit 'invalid environment variables not preserved'
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
foo() { return; }
 | 
			
		||||
false
 | 
			
		||||
foo && err_exit "'return' within function does not preserve exit status"
 | 
			
		||||
false
 | 
			
		||||
foo & wait "$!" && err_exit "'return' within function does not preserve exit status (bg job)"
 | 
			
		||||
 | 
			
		||||
foo() { false; return || :; }
 | 
			
		||||
foo && err_exit "'return ||' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; return && :; }
 | 
			
		||||
foo && err_exit "'return &&' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; while return; do true; done; }
 | 
			
		||||
foo && err_exit "'while return' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; while return; do true; done 2>&1; }
 | 
			
		||||
foo && err_exit "'while return' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; until return; do true; done; }
 | 
			
		||||
foo && err_exit "'until return' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; until return; do true; done 2>&1; }
 | 
			
		||||
foo && err_exit "'until return' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; for i in 1; do return; done; }
 | 
			
		||||
foo && err_exit "'return' within 'for' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; for i in 1; do return; done 2>&1; }
 | 
			
		||||
foo && err_exit "'return' within 'for' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; { return; } 2>&1; }
 | 
			
		||||
foo && err_exit "'return' within { block; } with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( exit )
 | 
			
		||||
false
 | 
			
		||||
foo && err_exit "'exit' within function does not preserve exit status"
 | 
			
		||||
false
 | 
			
		||||
foo & wait "$!" && err_exit "'exit' within function does not preserve exit status (bg job)"
 | 
			
		||||
 | 
			
		||||
foo() ( false; exit || : )
 | 
			
		||||
foo && err_exit "'exit ||' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; exit && : )
 | 
			
		||||
foo && err_exit "'exit &&' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; while exit; do true; done )
 | 
			
		||||
foo && err_exit "'while exit' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; while exit; do true; done 2>&1 )
 | 
			
		||||
foo && err_exit "'while exit' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; until exit; do true; done )
 | 
			
		||||
foo && err_exit "'until exit' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; until exit; do true; done 2>&1 )
 | 
			
		||||
foo && err_exit "'until exit' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; for i in 1; do exit; done )
 | 
			
		||||
foo && err_exit "'exit' within 'for' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; for i in 1; do exit; done 2>&1 )
 | 
			
		||||
foo && err_exit "'exit' within 'for' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; { exit; } 2>&1 )
 | 
			
		||||
foo && err_exit "'exit' within { block; } with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
set --
 | 
			
		||||
false
 | 
			
		||||
for i in "$@"; do :; done || err_exit 'empty loop does not reset exit status ("$@")'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -179,4 +179,74 @@ if	(( $? != 8 ))
 | 
			
		|||
then	err_exit "exit 8 in trap should set exit value to 8"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# ======
 | 
			
		||||
# Tests for 'return' and 'exit' without argument: they should pass down the previous exit status
 | 
			
		||||
 | 
			
		||||
foo() { return; }
 | 
			
		||||
false
 | 
			
		||||
foo && err_exit "'return' within function does not preserve exit status"
 | 
			
		||||
false
 | 
			
		||||
foo & wait "$!" && err_exit "'return' within function does not preserve exit status (bg job)"
 | 
			
		||||
 | 
			
		||||
foo() { false; return || :; }
 | 
			
		||||
foo && err_exit "'return ||' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; return && :; }
 | 
			
		||||
foo && err_exit "'return &&' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; while return; do true; done; }
 | 
			
		||||
foo && err_exit "'while return' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; while return; do true; done 2>&1; }
 | 
			
		||||
foo && err_exit "'while return' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; until return; do true; done; }
 | 
			
		||||
foo && err_exit "'until return' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; until return; do true; done 2>&1; }
 | 
			
		||||
foo && err_exit "'until return' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; for i in 1; do return; done; }
 | 
			
		||||
foo && err_exit "'return' within 'for' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; for i in 1; do return; done 2>&1; }
 | 
			
		||||
foo && err_exit "'return' within 'for' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() { false; { return; } 2>&1; }
 | 
			
		||||
foo && err_exit "'return' within { block; } with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( exit )
 | 
			
		||||
false
 | 
			
		||||
foo && err_exit "'exit' within function does not preserve exit status"
 | 
			
		||||
false
 | 
			
		||||
foo & wait "$!" && err_exit "'exit' within function does not preserve exit status (bg job)"
 | 
			
		||||
 | 
			
		||||
foo() ( false; exit || : )
 | 
			
		||||
foo && err_exit "'exit ||' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; exit && : )
 | 
			
		||||
foo && err_exit "'exit &&' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; while exit; do true; done )
 | 
			
		||||
foo && err_exit "'while exit' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; while exit; do true; done 2>&1 )
 | 
			
		||||
foo && err_exit "'while exit' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; until exit; do true; done )
 | 
			
		||||
foo && err_exit "'until exit' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; until exit; do true; done 2>&1 )
 | 
			
		||||
foo && err_exit "'until exit' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; for i in 1; do exit; done )
 | 
			
		||||
foo && err_exit "'exit' within 'for' does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; for i in 1; do exit; done 2>&1 )
 | 
			
		||||
foo && err_exit "'exit' within 'for' with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
foo() ( false; { exit; } 2>&1 )
 | 
			
		||||
foo && err_exit "'exit' within { block; } with redirection does not preserve exit status"
 | 
			
		||||
 | 
			
		||||
# ======
 | 
			
		||||
exit $((Errors<125?Errors:125))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue