The use of recursion in these functions (particularly in the way it is used, which prevents tail-call optimization), leads to increasing stack usage for every non-option argument, and eventually stack overflow. The recursion should probably be removed to avoid this (setting a variable within the functions to indicate that the function has restarted, along with a goto to the beginning and some other refactoring, might be a solution).