On 2020-07-04 00:35, Trevor Cordes wrote:
(Late to the party.)
You could use bash's eval in a while. Download your new code into a shell var (or a file you then open/read or slurp), like (psuedocode):
while (true) { newcode=`curl mynewcode` eval $newcode sleep }
That has no forks and allows you to update the code inside the while.
Other than that, I'm not sure why the shell is doing such weirdness. The infinite recursion is a bit of a surprise. Gilbert's supposition is probably on the right track.
If you have perl, it gives you finer-grained (C-ish level) control over exec-ish calls and might allow you to work around this problem. I find the Run3 module particularly useful. However, perl is probably overkill and it's not your favorite...
I don't mind Perl that much, but yeah it would be massive overkill. Ultimately, I gave in and had the script re-download itself, chmod itself, and then re-exec itself, and that's working more reliably than anything else I've tried so far, at the expense of leaving another file on disk in $CWD. If the extra file(s) ever become a huge problem, I could always add an EXIT trap, but it's not worth it yet.
Thanks, everyone, for the various suggestions! -Adam