On Tue, Nov 24, 2020 at 02:30:36PM +0100, Léa Gris wrote: > Should variables automatically created within arithmetic constructs have the > integer flag implied?
No. Please, no. It's bad enough that the -i flag exists in the first place, without it being randomly added to poor innocent variables. "Why did my code fail?" "Bash 5.69 added a feature that puts -i on your variables sometimes, if your first assignment to one just happens to occur inside an arithmetic context. And look here, you reused 'i' as both a numeric counter and a for loop iterator, but it just so happens the numeric counter usage occurred first, so you got slapped with the -i flag, and then your for loop iterator blew up." "OK, then why did this other script fail?" "You assumed that 'n' would get the integer flag automatically since you first assigned to it in a math command. But someone exported it as an environment variable before running your script, so it was already a string variable at the time. So you didn't get the -i flag on it." "AAAAAARGH!"