On 10/15/23 12:24 AM, Martin D Kealey wrote:
On Sun, 15 Oct 2023, 03:05 Greg Wooledge, <g...@wooledge.org> wrote:

On Sat, Oct 14, 2023 at 12:55:21PM -0400, Ti Strga wrote:
it's just the "[[ -v foo ]]" tests to see where along the cloning
process we are.

*Shudder*


Likewise, brrrr.

If the *real* goal is to overwrite a running script with a new version of
itself, and then re-exec it, then the correct solution is to wrap the
script in a single compound command so that it gets read and parsed up
front, before beginning execution of the main loop.  Either wrap the whole
thing in "{" ... "}" as Grisha suggested, or wrap the whole thing in a
"main()" function and then call main "$@".


Agreed. Either way, don't forget to put "exit;" just before the closing
"}". Or write « exec main "$@" ».

That's not going to work; `exec' doesn't work with shell functions. It
will exit the shell for you, though.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/


Reply via email to