patchelf icon indicating copy to clipboard operation
patchelf copied to clipboard

Introduce Finally to help track section rewrites

Open fzakaria opened this issue 3 years ago • 1 comments

Similarly to a concept used in NixOS/nix codebase, introduce the Finally class that can be given a lambda to execute on destructor.

The desired effect is to execute some code on a scope leave, in this case the method return.

This is used to make sure we only apply sectionRewrite once per modification and can now support early returns in the code paths.

CC @reidpr

fzakaria avatar Dec 22 '21 18:12 fzakaria

This is desired since I saw some pull-requests may add early returns in the codepaths. Rather than trying to track this across all pull-requests, I thought this approach similar to what Nix does might be sensible.

Open to discussion on it :)

fzakaria avatar Dec 22 '21 18:12 fzakaria