Product Site

7.4.29. ENDLOCAL (Linux only)

Restores the directory and environment variables in effect before the last SETLOCAL function was run. If ENDLOCAL is not included in a procedure, the initial environment saved by SETLOCAL is restored upon exiting the procedure.

ENDLOCAL returns a value of 1 if the initial environment is successfully restored and a value of 0 if no SETLOCAL was issued or the action is otherwise unsuccessful.

Example 7.41. Builtin function ENDLOCAL
n = SETLOCAL()                   /* saves the current environment */
          /*
          The program can now change environment variables
          (with the VALUE function) and then work in the
          changed environment.
          */
n = ENDLOCAL()                   /* restores the initial environment */

For additional examples, see Section 7.4.57, “SETLOCAL (Linux only)”.

Note

When used under Windows, ENDLOCAL always fails and returns 0.