Blame gl/tests/test-environ.c

Packit Service 4684c1
/* Test of environ variable.
Packit Service 4684c1
   Copyright (C) 2008-2020 Free Software Foundation, Inc.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software: you can redistribute it and/or modify
Packit Service 4684c1
   it under the terms of the GNU General Public License as published by
Packit Service 4684c1
   the Free Software Foundation; either version 3 of the License, or
Packit Service 4684c1
   (at your option) any later version.
Packit Service 4684c1
Packit Service 4684c1
   This program is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 4684c1
   GNU General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU General Public License
Packit Service 4684c1
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
/* Written by Bruno Haible <bruno@clisp.org>, 2008.  */
Packit Service 4684c1
Packit Service 4684c1
#include <config.h>
Packit Service 4684c1
Packit Service 4684c1
#include <unistd.h>
Packit Service 4684c1
Packit Service 4684c1
#include <string.h>
Packit Service 4684c1
Packit Service 4684c1
int
Packit Service 4684c1
main ()
Packit Service 4684c1
{
Packit Service 4684c1
  /* The environment variables that are set even in the weirdest situations
Packit Service 4684c1
     are HOME and PATH.
Packit Service 4684c1
     POSIX says that HOME is initialized by the system, and that PATH may be
Packit Service 4684c1
     unset.  But in practice it's more frequent to see HOME unset and PATH
Packit Service 4684c1
     set.  So we test the presence of PATH.  */
Packit Service 4684c1
  char **remaining_variables = environ;
Packit Service 4684c1
  char *string;
Packit Service 4684c1
Packit Service 4684c1
  for (; (string = *remaining_variables) != NULL; remaining_variables++)
Packit Service 4684c1
    {
Packit Service 4684c1
      if (strncmp (string, "PATH=", 5) == 0)
Packit Service 4684c1
        /* Found the PATH environment variable.  */
Packit Service 4684c1
        return 0;
Packit Service 4684c1
    }
Packit Service 4684c1
  /* Failed to find the PATH environment variable.  */
Packit Service 4684c1
  return 1;
Packit Service 4684c1
}