diff --git a/NEWS b/NEWS index af16cf6b9..6b9e2101a 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,11 @@ For full details, see the git log at: https://github.com/ksh93/ksh Any uppercase BUG_* names are modernish shell bug IDs. +2020-08-05: + +- Fixed a bug that caused scripts to continue running after over-shifting + in a function when the function call had a redirection. + 2020-07-31: - Fixed a bug that caused multidimensional associative arrays to be created diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h index 740def0ed..944606454 100644 --- a/src/cmd/ksh93/include/version.h +++ b/src/cmd/ksh93/include/version.h @@ -17,4 +17,4 @@ * David Korn * * * ***********************************************************************/ -#define SH_RELEASE "93u+m 2020-07-31" +#define SH_RELEASE "93u+m 2020-08-05" diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index baa8d6d12..0bc710a7d 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -1508,7 +1508,7 @@ int sh_exec(register const Shnode_t *t, int flags) unset_instance(nq,&node,&nr,mode); sh_funstaks(slp->slchild,-1); stakdelete(slp->slptr); - if(jmpval > SH_JMPFUN) + if(jmpval > SH_JMPFUN || (io && jmpval > SH_JMPIO)) siglongjmp(*shp->jmplist,jmpval); goto setexit; } diff --git a/src/cmd/ksh93/tests/functions.sh b/src/cmd/ksh93/tests/functions.sh index 7178bbf97..7374b29c6 100755 --- a/src/cmd/ksh93/tests/functions.sh +++ b/src/cmd/ksh93/tests/functions.sh @@ -1261,5 +1261,19 @@ function f2 { env | grep -q "^foo" || err_exit "Environment variable is not prop function f1 { f2; env | grep -q "^foo" || err_exit "Environment variable is not passed to a function"; } foo=bar f1 +# ====== +# Over-shifting in a POSIX function should terminate the script +$SHELL <<- \EOF + fun() { + shift 10 + } + for i in a b + do + fun 2> /dev/null + [[ $i == b ]] && exit 2 + done +EOF +[[ $? == 2 ]] && err_exit 'Over-shifting in a POSIX function does not terminate the script if the function call has a redirection' + # ====== exit $((Errors<125?Errors:125))