root/libutil/is_unixy.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. is_unixy

   1 /*
   2  * Copyright (c) 2001 Tama Communications Corporation
   3  *
   4  * Contributed by Jason Hood <jadoxa@yahoo.com.au>, 2001.
   5  *
   6  * This file is part of GNU GLOBAL.
   7  *
   8  * This program is free software: you can redistribute it and/or modify
   9  * it under the terms of the GNU General Public License as published by
  10  * the Free Software Foundation, either version 3 of the License, or
  11  * (at your option) any later version.
  12  * 
  13  * This program is distributed in the hope that it will be useful,
  14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16  * GNU General Public License for more details.
  17  * 
  18  * You should have received a copy of the GNU General Public License
  19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20  */
  21 
  22 #ifdef HAVE_CONFIG_H
  23 #include <config.h>
  24 #endif
  25 #if (defined(_WIN32) && !defined(__CYGWIN__)) || defined(__DJGPP__)
  26 #include <stdlib.h>
  27 #ifdef __DJGPP__
  28 #include <sys/system.h>
  29 #endif
  30 #endif
  31 
  32 #include "is_unixy.h"
  33 
  34 /**
  35  * is_unixy: whether running in a @NAME{unix}-like shell or not
  36  *
  37  *      @return         1: unixy shell, 0: @NAME{DOS} shell (@FILE{COMMAND.COM})
  38  */
  39 int
  40 is_unixy(void)
  41 {
  42 #if (defined(_WIN32) && !defined(__CYGWIN__)) || defined(__DJGPP__)
  43         static int unix_shell = -1;
  44 
  45         if (unix_shell == -1) {
  46                 char *s = getenv("SHELL");
  47 #ifdef __DJGPP__
  48                 /* Assume if SHELL isn't defined, COMSPEC is DOS. */
  49                 unix_shell = (s == NULL) ? 0 : _is_unixy_shell(s);
  50 #else
  51                 unix_shell = (s != 0);
  52 #endif
  53         }
  54         return unix_shell;
  55 #else
  56         return 1;
  57 #endif
  58 }

/* [previous][next][first][last][top][bottom][index][help] */