mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Revert 0e4c4d61
("Fix minor typeset attribute regressions")
This commit introduced the following bug, which is worse than the one that commit fixed: it became impossible to alter the size of an existing justified string attribute. Thanks to @hyenias for catching this bug: https://github.com/ksh93/ksh/issues/142#issuecomment-780931533 $ unset s; typeset -L 100 s=h; typeset +p s; typeset -L 5 s; typeset +p s typeset -L 100 s typeset -L 100 s Expected output: typeset -L 100 s typeset -L 5 s src/cmd/ksh93/sh/name.c: - Revert. src/cmd/ksh93/tests/attributes.sh: - Revert: re-disable tests for minor attribute output regressions. - Add a test for this bug and potential similar bugs.
This commit is contained in:
parent
241b5a4af5
commit
50b665b1ed
2 changed files with 21 additions and 5 deletions
|
@ -2985,10 +2985,11 @@ void nv_newattr (register Namval_t *np, unsigned newatts, int size)
|
|||
nv_onattr(np,NV_EXPORT);
|
||||
sh_envput(shp->env,np);
|
||||
}
|
||||
if((n^newatts)==NV_EXPORT && !trans)
|
||||
/* Only EXPORT attribute has changed and thus all work has been done. */
|
||||
return;
|
||||
}
|
||||
oldsize = nv_size(np);
|
||||
if(((n^newatts) & ~(NV_EXPORT|NV_RDONLY))==0)
|
||||
size = oldsize;
|
||||
if((size==oldsize|| (n&NV_INTEGER)) && !trans && ((n^newatts)&~NV_NOCHANGE)==0)
|
||||
{
|
||||
if(size>0)
|
||||
|
|
|
@ -526,16 +526,16 @@ typeset -A expect=(
|
|||
[F12]='typeset -x -r -F 12 foo'
|
||||
[H]='typeset -x -r -H foo'
|
||||
[L]='typeset -x -r -L 0 foo'
|
||||
[L17]='typeset -x -r -L 17 foo'
|
||||
# [L17]='typeset -x -r -L 17 foo' # TODO: outputs '-L 0'
|
||||
[Mtolower]='typeset -x -r -l foo'
|
||||
[Mtoupper]='typeset -x -r -u foo'
|
||||
[R]='typeset -x -r -R 0 foo'
|
||||
[R17]='typeset -x -r -R 17 foo'
|
||||
# [R17]='typeset -x -r -R 17 foo' # TODO: outputs '-L 0'
|
||||
[X17]='typeset -x -r -X 17 foo'
|
||||
[S]='typeset -x -r foo'
|
||||
[T]='typeset -x -r foo'
|
||||
[Z]='typeset -x -r -Z 0 -R 0 foo'
|
||||
[Z13]='typeset -x -r -Z 13 -R 13 foo'
|
||||
# [Z13]='typeset -x -r -Z 13 -R 13 foo' # TODO: outputs 'typeset -x -r -Z 0 -R 0 foo'
|
||||
)
|
||||
for flag in "${!expect[@]}"
|
||||
do unset foo
|
||||
|
@ -614,5 +614,20 @@ do unset a
|
|||
done
|
||||
unset expect
|
||||
|
||||
# ======
|
||||
# https://github.com/ksh93/ksh/issues/142#issuecomment-780931533
|
||||
got=$(unset s; typeset -L 100 s=h; typeset +p s; typeset -L 5 s; typeset +p s)
|
||||
exp=$'typeset -L 100 s\ntypeset -L 5 s'
|
||||
[[ $got == "$exp" ]] || err_exit 'cannot alter size of existing justified string attribute' \
|
||||
"expected $(printf %q "$exp"), got $(printf %q "$got")"
|
||||
got=$(unset s; typeset -L 100 s=h; typeset +p s; typeset -R 5 s; typeset +p s)
|
||||
exp=$'typeset -L 100 s\ntypeset -R 5 s'
|
||||
[[ $got == "$exp" ]] || err_exit 'cannot set -R after setting -L' \
|
||||
"expected $(printf %q "$exp"), got $(printf %q "$got")"
|
||||
got=$(unset s; typeset -L 100 s=h; typeset +p s; typeset -Z 5 s; typeset +p s)
|
||||
exp=$'typeset -L 100 s\ntypeset -Z 5 -R 5 s'
|
||||
[[ $got == "$exp" ]] || err_exit 'cannot set -Z after setting -L' \
|
||||
"expected $(printf %q "$exp"), got $(printf %q "$got")"
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue