1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix 'typeset -xu', 'typeset -xl' (rhbz#1188377)

'typeset -xu' and 'typeset -xl' would export the variable but fail
to change case in the value under certain conditions.

Original patch:
642af4d6/f/ksh-20120801-xufix.patch

This applies the patch essentially without change and adds a
regression test based on the reproducer provided in the RH bug.

Unfortunately there is no description of how the patch works and
it's a little obscure to me. As far as I can figure out, the cause
of the problem was that nv_newattr() erroneously processed a
nonexistent size option-argument such as what can be given to
options like typeset -F, e.g. typeset -F3 for 3 digits after the
dot. A nonexistent size argument is represented by the value of -1.
This commit is contained in:
Martijn Dekker 2020-09-30 00:34:02 +02:00
parent ba0b1bba2b
commit fdb9781ebb
5 changed files with 27 additions and 2 deletions

View file

@ -30,6 +30,23 @@ integer Errors=0
[[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
# ======
# as of 93u+, typeset -xu/-xl failed to change case in a value (rhbz#1188377)
# (this test failed to fail when it was added at the end, so it's at the start)
unset test_u test_xu test_txu
typeset -u test_u=uppercase
typeset -xu test_xu=uppercase
typeset -txu test_txu=uppercase
typeset -l test_l=LOWERCASE
typeset -xl test_xl=LOWERCASE
typeset -txl test_txl=LOWERCASE
exp="UPPERCASE UPPERCASE UPPERCASE lowercase lowercase lowercase"
got="${test_u} ${test_xu} ${test_txu} ${test_l} ${test_xl} ${test_txl}"
[[ $got == "$exp" ]] || err_exit "typeset failed to change case in variable" \
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
unset ${!test_*}
# ======
r=readonly u=Uppercase l=Lowercase i=22 i8=10 L=abc L5=def uL5=abcdef xi=20
x=export t=tagged H=hostname LZ5=026 RZ5=026 Z5=123 lR5=ABcdef R5=def n=l
for option in u l i i8 L L5 LZ5 RZ5 Z5 r x H t R5 uL5 lR5 xi n