40a95b6355a1e83574c69c3769b13b1c67e01e11
[platform/upstream/bash.git] / lib / tilde / shell.c
1 /* shell.c -- tilde utility functions that are normally provided by
2               bash when readline is linked as part of the shell. */
3
4 /* Copyright (C) 1998-2009 Free Software Foundation, Inc.
5
6    This file is part of the GNU Tilde Library.
7
8    The GNU Tilde Library is free software: you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as published
10    by the Free Software Foundation, either version 3 of the License, or
11    (at your option) any later version.
12
13    The GNU Tilde Library 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 the GNU Tilde Library.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #if defined (HAVE_CONFIG_H)
23 #  include <config.h>
24 #endif
25
26 #if defined (HAVE_UNISTD_H)
27 #  ifdef _MINIX
28 #    include <sys/types.h>
29 #  endif
30 #  include <unistd.h>
31 #endif /* HAVE_UNISTD_H */
32
33 #if defined (HAVE_STDLIB_H)
34 #  include <stdlib.h>
35 #else
36 #  include "ansi_stdlib.h"
37 #endif /* HAVE_STDLIB_H */
38
39 #if defined (HAVE_STRING_H)
40 #  include <string.h>
41 #else
42 #  include <strings.h>
43 #endif /* !HAVE_STRING_H */
44
45 #include <pwd.h>
46
47 #if !defined (HAVE_GETPW_DECLS)
48 extern struct passwd *getpwuid ();
49 #endif /* !HAVE_GETPW_DECLS */
50
51 char *
52 get_env_value (varname)
53      char *varname;
54 {
55   return ((char *)getenv (varname));
56 }
57
58 char *
59 get_home_dir ()
60 {
61   char *home_dir;
62   struct passwd *entry;
63
64   home_dir = (char *)NULL;
65   entry = getpwuid (getuid ());
66   if (entry)
67     home_dir = entry->pw_dir;
68   return (home_dir);
69 }