:REGISTER_VARIABLE truncates a backslash at the end and adds an apostrophe

Document ID : KB000084825
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:
Error Message :
N/A

The Script statement :REGISTER_VARIABLE on an OS variable that has a backslash at the end, cuts off the backslash, and fills in an apostrophe.

Investigation
 
+Process:+
echo on
!
set somevar=\Schub\iduba\
!
@set retcode=%errorlevel%
@if NOT %ERRORLEVEL% == 0 goto :retcode
!
echo %PSModulePath%
echo %somevar%
!
@set retcode=%errorlevel%
@if NOT %ERRORLEVEL% == 0 goto :retcode
!
:register_variable WIN_VAR#,%PSModulePath%
:register_variable SOMEVAR#,%somevar%

+Post_Process:+
:PRINT ">&WIN_VAR#<"
:PRINT ">&SOMEVAR#<"

+Report:+
c:\>echo on

c:\>set somevar=\Schub\iduba\

c:\>echo C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules\
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules\

c:\>echo \Schub\iduba\
\Schub\iduba\

c:\>C:\uc4\V112\agents\V112_WIN02\bin\UCXJWX6M.EXE JNR=0001600210 MNR=0001 PNR=11231 IPA=127.0.0.1 TYP=V VTYPE=T NAME=WIN_VAR# VALUE="C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules\"

c:\>C:\uc4\V112\agents\V112_WIN02\bin\UCXJWX6M.EXE JNR=0001600210 MNR=0001 PNR=11231 IPA=127.0.0.1 TYP=V VTYPE=T NAME=SOMEVAR# VALUE="\Schub\iduba\"

c:\>C:\uc4\V112\agents\V112_WIN02\bin\UCXJWX6M.EXE JNR=0001600210 MNR=0001 PNR=11231 IPA=127.0.0.1 TYP=E RET=00000000 TXT=" Job ended"


+Post Process Report:+
2017-12-14 21:10:51 - U00020206 Variable '&SOMEVAR#' was stored with value '\Schub\iduba"'.
2017-12-14 21:10:51 - U00020206 Variable '&WIN_VAR#' was stored with value 'C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules"'.
2017-12-14 21:10:51 - U00020408 >C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules"<
2017-12-14 21:10:51 - U00020408 >\Schub\iduba"<
Environment:
OS Version: N/A
Cause:
Cause type:
By design
Root Cause: The behavior is caused by the executing shell, which interprets the last backslash as your wish to escape the following character, which happens to be a ".
Resolution:
This is not a bug, and independent from any database. The behavior is caused by the executing shell, which interprets the last backslash as your wish to escape the following character, which happens to be a ".

The following line is sent to cmd.exe:
C:\Automic\12.1\Automation.Platform\Agents\windows\bin\UCXJWX6M.EXE JNR=0001141045 MNR=0666 PNR=2300 IPA=10.243.20.123 TYP=V VTYPE=T NAME=SOMEVAR2# VALUE="\Schub\iduba\"

 

Fix Status: No Fix

Fix Version(s):
N/A
Additional Information:
Workaround :
Escape the last \ with another one, or add a blank.