You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of problem:
When a function scoped variable is set in the body of a while loop, the variable appears to lose the value when the loop is restarted.
Ksh version:
# print -v .sh.version
Version AJM 93u+ 2012-08-01
How reproducible:
Easily reproduced from console. The output from dash, and bash, is less surprising:
$ dash /tmp/foo.sh | head -4
/tmp/foo.sh: 11: print: not found
/tmp/foo.sh: 13: typeset: not found
+
+
+
Steps to reproduce:
$ cat /tmp/foo.sh
f()
{
typeset X
while : ; do
echo "${X++}"
X=1
done
}
print -v .sh.version
f
$ ksh /tmp/bug.sh | head
Version AJM 93u+ 2012-08-01
```
The text was updated successfully, but these errors were encountered:
Well, your script works as expected: you set X=1 and echo the contents of another var named X++. Since you never set the value of this var, it is empty - you get, what you are asking for.
dash is obviously buggy wrt. the output of the script.
Description of problem:
When a function scoped variable is set in the body of a while loop, the variable appears to lose the value when the loop is restarted.
Ksh version:
How reproducible:
Easily reproduced from console. The output from dash, and bash, is less surprising:
Steps to reproduce:
The text was updated successfully, but these errors were encountered: