cc: [email protected] Subject: Re: [ast-developers] ksh crash -------- > Hi, > > while playing with OOP features, our engineer found following crash: > ====================== [cut] ========================= > #!/bin/ksh > typeset -T Something_t=( > typeset -liSh 'number of objects' count=0 > typeset -lih 'some value' value=0 > > create() { > print "creation" > ((_.count++)) > } > ) > > .sh.type.Something_t=(value=42) > Something_t n1=() > Something_t n2=n1 > > echo "Number of objects: ${n1.count}, value=${n1.value}" > ====================== [cut] ========================= The problem is that the .sh.type variable should be readonly by scripts. If you remove the lie .sh.type.Something_t=(value=42) it should not core dump. I will make .sh.type readonly for the next release. > > > Also I'd like to ask a question about aliases. Right now, if alias is > set inside of a sourced script, it does not have effect on sourced > script itself. For example: > > testA.sh: > #!/bin/ksh > . ./testB.sh > echo "A\nB\nC\n" > > testB.sh: > alias echo='echo -e' > alias echo > type echo > echo "1\n2\n\3\n" > > output is: > echo='echo -e' > echo is an alias for 'echo -e' > 1\n2\n\3\n > A > B > C > > Is this expected behaviour? Yes, this is documented behavior. aliases are expanded when reading a script and a dot script is read in its entirety before running any commands. Therefore, any aliases defined in a . script (or function) will not take effect for that dot script or function.
However, profile files are read an processed one command at a time unlike dot scripts. > > Also I was asked whether ksh is expected to segfault on too deep > recursion. I think the answer is yes, but I'm asking because I was asked > for official answer. Anyway, from what I've tested, all shells crashes > except zsh that prints something like "recursion too deep" and terminates. There is a limit (currently 1024) and when you pass that limit, ksh93 will say recursion too deep. However, it is possible to exceed the stack size on some systems before that limit is reached when leads to a core dump. > > Michal > _______________________________________________ > ast-developers mailing list > [email protected] > https://mailman.research.att.com/mailman/listinfo/ast-developers > David Korn [email protected] _______________________________________________ ast-developers mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-developers
