OS/2 tricks: setlocal/endlocal and beginlibpath/endlibpath

setlocal/endlocal is a command to save current environmental variabls and to restore them, again. So they are usually at beginning and at end of a batch file or of a rexx file, respectively.

However, there is a pitfall here. setlocal/endlocal do not work with beginlibpath/endlibpath. Because beginlibpath/endlibpath are not real environmental variables. Instead, command interpreter such as CMD and 4OS2, treat them like environmental variables.

Because of this, if you modify beginlibpath/endlibpath in setlocal/endlocal block, then original beginlibpath/endlibpath are not resotred after endlocal.

This is observed on both CMD and 4OS2. So you should use a workaround. It's simple. Just backup beginlibpath/endlibpath and restore them manually.

Use this pattern.

1
2
3
4
5
setlocal
set oldb=%beginlibpath%
rem your codes
set beginlibpath=%oldb%
endlocal


// ----- 2014/09/24
LIBPATHSTRICT is not restored, too.
//

댓글

이 블로그의 인기 게시물

토렌트: < 왕좌의 게임 > 시즌 1 ~ 시즌 8 완결편 마그넷

토렌트: < 스타워즈 > Ep.1 ~ Ep.6 마그넷

토렌트: NGC < 코스모스 > 우리말 더빙 전편(1편~13편) 마그넷