1
0
Fork 0
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:
Martijn Dekker 2021-02-18 01:07:43 +00:00
parent 241b5a4af5
commit 50b665b1ed
2 changed files with 21 additions and 5 deletions

View file

@ -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)