diff -up ksh-20100621/src/cmd/ksh93/sh/name.c.fixexport ksh-20100621/src/cmd/ksh93/sh/name.c --- ksh-20100621/src/cmd/ksh93/sh/name.c.fixexport 2010-05-24 20:32:32.000000000 +0200 +++ ksh-20100621/src/cmd/ksh93/sh/name.c 2012-07-19 13:03:49.351524835 +0200 @@ -2712,9 +2712,17 @@ void nv_newattr (register Namval_t *np, { /* record changes to the environment */ if(n&NV_EXPORT) + { + nv_offattr(np,NV_EXPORT); env_delete(sh.env,nv_name(np)); + } else + { + nv_onattr(np,NV_EXPORT); sh_envput(sh.env,np); + } + if((n^newatts)==NV_EXPORT) + return; } oldsize = nv_size(np); if((size==oldsize|| (n&NV_INTEGER)) && ((n^newatts)&~NV_NOCHANGE)==0) diff -up ksh-20100621/src/cmd/ksh93/tests/attributes.sh.fixexport ksh-20100621/src/cmd/ksh93/tests/attributes.sh --- ksh-20100621/src/cmd/ksh93/tests/attributes.sh.fixexport 2010-05-24 20:44:54.000000000 +0200 +++ ksh-20100621/src/cmd/ksh93/tests/attributes.sh 2012-07-19 13:05:04.935121202 +0200 @@ -371,4 +371,11 @@ x=$($SHELL -c 'integer -s x=5;print -r - } 2> /dev/null [[ $x == 5 ]] || err_exit 'integer -s not working' -exit $((Errors)) +unset foo +typeset -Z2 foo=3 +[[ $(typeset -p foo) == 'typeset -Z 2 -R 2 foo=03' ]] || err_exit '-Z2 not working' +export foo +[[ $(typeset -p foo) == 'typeset -x -Z 2 -R 2 foo=03' ]] || err_exit '-Z2 not working after export' + +exit $((Errors<125?Errors:125)) +