too eager expansion in substitution

Bug #1798397 reported by Thorsten Glaser
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mksh
Invalid
Medium
Unassigned

Bug Description

“If word is not needed, it shall not be expanded.” (POSIX)

00:52 < izabera> i=42; : ${var#${q[i=777]}}; echo $i; var=meow; : ${var#${q[i=777]}}; echo $i
00:52 < izabera> prints 42 777 in bash and ksh93
00:52 < izabera> and 777 777 in mkmsh

The #/##/%/%% of course need to expand word first.

Thanks to jilles for the heads-up.

Revision history for this message
Thorsten Glaser (mirabilos) wrote :

Found to be not a bug:

$ i=42; : ${var#${q[i=777]}}; echo $i; var=meow; : ${var#${q[i=777]}}; echo $i

must return 777 twice, because the pattern must always be expanded before looking at $var.

$ i=42; : ${var+${q[i=777]}}; echo $i; var=meow; : ${var+${q[i=777]}}; echo $i

already behaves correctly (42 then 777).

Changed in mksh:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.