Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow shutdown-hook to run functions #4200

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

roccoblues
Copy link
Member

@roccoblues roccoblues commented Mar 18, 2024

This adds support for function execution (exec sync-mailbox) to the shutdown-hook.

Notes:

  • only Index and "Global" functions are supported

  • the functions are only exectured after the whole hook is parsed. So in this example:

    shutdown-hook "echo 'before'; exec sync-mailbox; echo 'after'"
    

    the order of execution will be:

    1. before
    2. after
    3. sync-mailbox
  • run_events() is a terrible name and the method is probably in the wrong place

Related to: #4184

@roccoblues roccoblues self-assigned this Mar 18, 2024
@roccoblues roccoblues force-pushed the roccoblues/hook-functions branch 4 times, most recently from e856e99 to 0938d26 Compare March 18, 2024 15:35
@gahr
Copy link
Member

gahr commented Mar 20, 2024

the functions are only exectured after the whole hook is parsed. So in this example:
shutdown-hook "echo 'before'; exec sync-mailbox; echo 'after'"
the order of execution will be:

before
after
sync-mailbox

Not a fan of this "feature" :) Can we do better?

@roccoblues
Copy link
Member Author

the functions are only exectured after the whole hook is parsed. So in this example:
shutdown-hook "echo 'before'; exec sync-mailbox; echo 'after'"
the order of execution will be:
before
after
sync-mailbox

Not a fan of this "feature" :) Can we do better?

yeah, same here. But fixing this will require bigger changes. Because the code that parses the hooks and exec statements is pretty low level. I'll have another look. If you have any ideas - shoot. ;-)

@flatcap flatcap force-pushed the roccoblues/hook-functions branch 3 times, most recently from 03b2756 to fcc7c08 Compare March 29, 2024 01:44
@roccoblues roccoblues force-pushed the roccoblues/hook-functions branch 2 times, most recently from 8c901bc to 2c5682a Compare April 8, 2024 13:52
hook.c Fixed Show fixed Hide fixed
@flatcap flatcap force-pushed the roccoblues/hook-functions branch from 265e4dc to 540402e Compare May 8, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants