#503 Allow function calls without "un." in uninstallr& vice versa

2.0 Series
open
Amir Szekely
Scripting (152)
5
2011-01-28
2011-01-28
Anonymous
No

Currently any NSIS script function (not a method within a plugin) called from an uninstall section, directly or indirectly must have a name beginning with "un.". On the other hand, any NSIS script function called from an install section, directly or indirectly must NOT have a name beginning with "un."

This makes it impossible to share common code between installer and uninstaller without enclosing the function inside a macro:

!macro MYMACRO un
Function ${un}myfunc
DetailPrint "Oh this is a very funny restriction on function names!"
FunctionEnd
!macroend

So, include files like TextLog.nsh cannot be used in the uninstaller as its functions are not inside a macro.

It will be a good idea to remove this restriction on function names. An alternative solution is to allow functions whose names begin with say, "both.", to be called from both installer and uninstaller code and allow the "both." functions to call any function, "un.", "both." and other functions.

Discussion

  • Anders
    Anders
    2011-01-28

    Yes, removing the prefix would be nice, there is another request on the tracker to remove (and not just zero) unused functions, if that was fixed .un would no longer be needed.

    In the mean time, use the macro in \NSIS\Include\Util.nsh for automatic function generation