YunoHost-Apps / Experimental_helpers

6 stars 12 forks source link

Force cleanup even on error when installing ruby #105

Open fflorent opened 1 year ago

fflorent commented 1 year ago

Problem

There are theoretically some cases where the installer is interrupted because of failures or because the user triggers the interruption.

In such case, there is no guarantee that the ruby binary is restored.

Solution

Use a sub-shell with a trap of exit (the cleanup function. Whether the sub-shell fails or suceeds, the trap is run.