Archive: INSTDIR escape characters


INSTDIR escape characters
I noticed that when I put the $INSTDIR in a string some characters will be escaped.

For example If the user chooses C:\temp as the installation directory. It will show up as "C: emp" in some of my pages....


How can I make sure it appears right knowing that the user might choose anything (directories that contain \t \n \r for examples)


I can't reproduce this.
Attach your script.


One solution would be to change all "\" to "\\" in the $INSTDIR but I am wondering if there is a better solution. If not is there any NSIS function that replaces "\" by "\\" in a variable? thanks.


Please note that this problem happens only in pages not in a MessageBox. Here is a minimal example :



!include "MUI.nsh"
!include "Sections.nsh"
Name "test"
OutFile "test.exe"
!define MUI_ABORTWARNING

!insertmacro MUI_PAGE_DIRECTORY
Page custom Confirm "" ": Confirm installation options"
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"


InstallDir "C:\temp\now\rats"
Section test
MessageBox MB_OK "$INSTDIR"
SectionEnd

Function Confirm
!insertmacro MUI_HEADER_TEXT "Confirm installation options" ""

!insertmacro MUI_INSTALLOPTIONS_WRITE "Fluent_Confirm.ini" "Settings" "NumFields" "1"
!insertmacro MUI_INSTALLOPTIONS_WRITE "Fluent_Confirm.ini" "Field 1" "Type" "Label"
!insertmacro MUI_INSTALLOPTIONS_WRITE "Fluent_Confirm.ini" "Field 1" "Left" "10"
!insertmacro MUI_INSTALLOPTIONS_WRITE "Fluent_Confirm.ini" "Field 1" "Right" "-10"
!insertmacro MUI_INSTALLOPTIONS_WRITE "Fluent_Confirm.ini" "Field 1" "Top" "10"
!insertmacro MUI_INSTALLOPTIONS_WRITE "Fluent_Confirm.ini" "Field 1" "Bottom" "-10"
!insertmacro MUI_INSTALLOPTIONS_WRITE "Fluent_Confirm.ini" "Field 1" "Text" "The install directory is $INSTDIR"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY Fluent_Confirm.ini
FunctionEnd

Function .onInit
InitPluginsDir
FunctionEnd


It appears to be a bug with the MUI_INSTALLOPTIONS_WRITE macro.
See the attached script.
Writing $INSTDIR to the registry using WriteRegStr or to an INI file using WriteINIStr seems to work fine.

[edit]
Nope, I think it is a bug with the InstallOptions plugin. Or should I call it an undocumented feature? ;)
[/edit]


It's not a bug. Read the InstallOptions documentation.


You're right. I must be losing it. :)
I actually am doing the escaping of the slash in my own scripts.
I guess I have been away from NSIS too long. :)