The subroutine is called by:
call getenv( ename, evalue ) |
|||
ename |
character*n |
Input |
Name of the environment variable sought |
evalue |
character*n |
Output |
Value of the environment variable found; blanks if not successful |
The size of ename and evalue must be large enough to hold their respective character strings.
If evalue is too short to hold the complete string value, the string is truncated to fit in evalue.
The getenv subroutine searches the environment list for a string of the form ename=evalue and returns the value in evalue if such a string is present; otherwise, it fills evalue with blanks.
Example: Use getenv() to print the value of $SHELL:
character*18 evalue call getenv( ’SHELL’, evalue ) write(*,*) "’", evalue, "’" end |
See also: execve(2) and environ(5).