JFLarvoire / SysToolsLib

A library of Windows and Linux system management tools
Apache License 2.0
314 stars 93 forks source link

Library.bat - Error on Multiple Load sequence #9

Closed bbourgier closed 7 years ago

bbourgier commented 7 years ago

Hi,

I was trying and use your Library.bat framework in a script of mine, by sourcing it. Library.bat version 2016-12-16 And I happened to have the following sequence call:

call "Library.bat" source
%LCALL% :Debug.On
call "Library.bat" source

and I get the following error:

The system cannot find the batch label specified - Debug.1

I looked at Library.bat and I found a surprising fix to this error: Add a simple comment line after the line: goto :Debug.%DEBUG%

Which gives for instance:

goto :Debug.%DEBUG%
:# END

:Debug.SetLog

Do you validate this fix?

Thks.

JFLarvoire commented 7 years ago

Hi, I don't understand why you're doing this: Sourcing the library should only be done once. Afterwards, all the library resources are available to the calling script. If I were to make a change, it would be to insert a test at the very beginning of library.bat, and immediately return on an attempt to source it again.

bbourgier commented 7 years ago

Hi, The call sequence I told you about was just a sum up to do my case. In fact load calls are not done at all at the same place. And I understand your remark. However as long as it is possible to load several time, then this error case should probably be handled internally to the library in order to avoid multi-loading while sourcing. Therefore yes, if you could handle this case internally, this would be great indeed! Thks again.

JFLarvoire commented 7 years ago

I tried reproducing the issue, but I don't get any error. Please try again with the updated Library.bat that I just checked in. It contains several overdue changes, including one that affects the %LCALL% macro. Maybe this will help on your system. (Note that I also tried the test with the 2016-12-16 version, and I did not get any error either.) What version of Windows are you using?

bbourgier commented 7 years ago

Hi, Forget about it. The issue was due to the wrong EOL encoding when I copy pasted your code from github. For some strange reason it was Unix encoding (CR). When converting it to Windows encoding (CRLF) everything works well. I don't have the "cannot find batch label" error anymore. Thank you for your patience :-)