3 ms·
Unfortunately, the stack grows with the length of the goto chain! Each goto starts a new call to the jump function, which never returns: the embedded eval conta
by kazinator 10y ago
Unfortunately, the stack grows with the length of the goto chain! Each goto starts a new call to the jump function, which never returns: the embedded eval contains another goto which invokes the function again, and so on. The function and eval frames will pile up and eventually blow the shell's stack. Associated with each eval frame is a copy of an entire suffix of the script starting at the target label, too, held in the string variable which captures the output of sed.
I have just coined a name for this crude technique: "trumpolines". Under this nomenclature, the program is said to construct a trumpoline by extracting a suffix of itself beginning with the label into a local variable, and then effectively branches to it via eval.
This is vaguely reminiscent of "trampolines" in compiled languages like C, whereby machine code is constructed in local storage (on the stack) and then branched to (requiring an executable stack). GCC uses trampolines for indirection on pointers to GNU C nested functions.
Trumpolines are so named because they will trump the process's memory and stack resources.