Product SiteDocumentation Site

7.4.29. ENDLOCAL (Linux only)


>>-ENDLOCAL()--------------------------------------------------><

Restores the directory and environment variables in effect before the last SETLOCAL (Section 7.4.56, “SETLOCAL (Linux only)” 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.
Here is an example:

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.56, “SETLOCAL (Linux only)”.