Deletes an environment variable for the current environment using the C standard library Returns an error if the variable did not exist in the first place
C strings
Call setenv
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | name |
Variable name |
logical function delete_env(name) result(success) !> Variable name character(*), intent(in) :: name ! Local variables integer(c_int) :: cerr character(kind=c_char,len=1), allocatable :: c_name(:) interface integer(c_int) function c_unsetenv(envname) bind(C,name="c_unsetenv") import c_int, c_char implicit none !> Pointer to the name string character(kind=c_char,len=1), intent(in) :: envname(*) end function c_unsetenv end interface !> C strings call f2cs(name,c_name) !> Call setenv #ifndef FPM_BOOTSTRAP cerr = c_unsetenv(c_name) #endif success = cerr==0_c_int end function delete_env