Opened 7 years ago

Last modified 7 years ago

#78 assigned defect

Error level for "bbackupquery.exe -u"

Reported by: Achim J Latz Owned by: chris
Priority: normal Milestone:
Component: bbackupd Version: 0.11rc2
Keywords: Cc:


Using bbackupquery.exe to compare in batch mode ("compare -a -q -c" quit) works fine, and the ERRORLEVEL variable in cmd.exe is set to 2 when a comparison failed.

Adding the "-u" switch to compare non-ASCII file names will cause bbackupquery.exe to NEVER return ERRORLEVEL=2, even if the comparison failed.

Not sure whether this is an issue with cmd.exe or bbackupquery.exe

Change History (2)

comment:1 Changed 7 years ago by Achim J Latz

Well, it turns out that not only %ERRORLEVEL% is broken, effectively any kind of cmd magic does not work anymore after running a bbackupquery.exe instance with the "-u" switch:

This works:

"%~dp0\\bbackupquery.exe" -q -c %1 "compare -a -q -c" quit > %temp%\compare_backup_output.txt 2>&1
FOR %%F IN (%temp%\compare_backup_output.txt) DO IF %%~zF NEQ 0 (
	echo Comparison failed with error: %errorlevel%
	type "%temp%\compare_backup_output.txt"
        exit /b %errorlevel%

This does not (only change: passing "-u" to bbackupquery.exe:

"%~dp0\\bbackupquery.exe" -u -q -c %1 "compare -a -q -c" quit > %temp%\compare_backup_output.txt 2>&1
FOR %%F IN (%temp%\compare_backup_output.txt) DO IF %%~zF NEQ 0 (
	echo Comparison failed with error: %errorlevel%
	type "%temp%\compare_backup_output.txt"
        exit /b %errorlevel%

The first .cmd shows the differences between local and remote, if the file size of the resulting "diff" output from bbackupquery.exe is > 0. The second example should achieve the same (and respect non-ASCII characters), but it always stops after the line with bbackupquery.exe: no other commands are executed after that.

For fun, insert a line with only "notepad.exe" before the FOR loop: it gets executed every time in the first cmd, never in the second!

You can see that I originally thought that only the ERRORLEVEL comparison was broken (hence I came up with the size comparison hack...), but even that does not work because it appears as if bbackupquery.exe breaks something with the -u switch in cmd.exe.

comment:2 Changed 7 years ago by chris

Owner: changed from ben to chris
Status: newassigned

It looks like we might have to restore the console code page when bbackupquery exits, as in this example:

I've never had a problem with using bbackupquery interactively, so didn't notice this, but perhaps cmd.exe does it automatically in interactive mode, or when displaying the prompt.

Note: See TracTickets for help on using tickets.