]> git.ipfire.org Git - thirdparty/bash.git/blame - lib/tilde/shell.c
Imported from ../bash-4.0-rc1.tar.gz.
[thirdparty/bash.git] / lib / tilde / shell.c
CommitLineData
b72432fd
JA
1/* shell.c -- tilde utility functions that are normally provided by
2 bash when readline is linked as part of the shell. */
3
3185942a 4/* Copyright (C) 1998-2009 Free Software Foundation, Inc.
b72432fd
JA
5
6 This file is part of the GNU Tilde Library.
7
3185942a
JA
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
b72432fd
JA
11 (at your option) any later version.
12
3185942a
JA
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
b72432fd
JA
16 GNU General Public License for more details.
17
3185942a
JA
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*/
b72432fd
JA
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)
48extern struct passwd *getpwuid ();
49#endif /* !HAVE_GETPW_DECLS */
50
51char *
52get_env_value (varname)
53 char *varname;
54{
55 return ((char *)getenv (varname));
56}
57
58char *
59get_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}