MSYS shell keeping script file open, preventing modifications MSYS shell keeping script file open, preventing modifications shell shell

MSYS shell keeping script file open, preventing modifications


You could let the script re-exec itself. Split it like this:

#!/bin/shif test -z "$MYSCRIPT_REEXEC"; then    : stuff you do before git pull    exec env MYSCRIPT_REEXEC=1 sh -c "git pull; . '$0'"fi: stuff you do after git pull

This is a simple case, $0 may not contain apostrophs, and the arguments and any variables set in the first half are inaccessible. It’s hard to give a better generic example – maybe, if I could see the original script?

If this still does not work, try this one:

#!/bin/shif test -z "$MYSCRIPT_REEXEC"; then    : stuff you do before git pull    env MYSCRIPT_REEXEC=1 sh -c "sleep 1; git pull; . '$0'" &    exit 0fi: stuff you do after git pull

In this case, though, return codes will also be all wrong, as will anything waiting for the script.