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 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
|
---|
9 | and/or modify it under the terms of the GNU General Public License
|
---|
10 | as published by the Free Software Foundation; either version 2, or
|
---|
11 | (at your option) any later version.
|
---|
12 |
|
---|
13 | The GNU Tilde Library is distributed in the hope that it will be
|
---|
14 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
---|
15 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | GNU General Public License for more details.
|
---|
17 |
|
---|
18 | The GNU General Public License is often shipped with GNU software, and
|
---|
19 | is generally kept in a file called COPYING or LICENSE. If you do not
|
---|
20 | have a copy of the license, write to the Free Software Foundation,
|
---|
21 | 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
---|
22 |
|
---|
23 | #if defined (HAVE_CONFIG_H)
|
---|
24 | # include <config.h>
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | #if defined (HAVE_UNISTD_H)
|
---|
28 | # ifdef _MINIX
|
---|
29 | # include <sys/types.h>
|
---|
30 | # endif
|
---|
31 | # include <unistd.h>
|
---|
32 | #endif /* HAVE_UNISTD_H */
|
---|
33 |
|
---|
34 | #if defined (HAVE_STDLIB_H)
|
---|
35 | # include <stdlib.h>
|
---|
36 | #else
|
---|
37 | # include "ansi_stdlib.h"
|
---|
38 | #endif /* HAVE_STDLIB_H */
|
---|
39 |
|
---|
40 | #if defined (HAVE_STRING_H)
|
---|
41 | # include <string.h>
|
---|
42 | #else
|
---|
43 | # include <strings.h>
|
---|
44 | #endif /* !HAVE_STRING_H */
|
---|
45 |
|
---|
46 | #include <pwd.h>
|
---|
47 |
|
---|
48 | #if !defined (HAVE_GETPW_DECLS)
|
---|
49 | extern struct passwd *getpwuid ();
|
---|
50 | #endif /* !HAVE_GETPW_DECLS */
|
---|
51 |
|
---|
52 | char *
|
---|
53 | get_env_value (varname)
|
---|
54 | char *varname;
|
---|
55 | {
|
---|
56 | return ((char *)getenv (varname));
|
---|
57 | }
|
---|
58 |
|
---|
59 | char *
|
---|
60 | get_home_dir ()
|
---|
61 | {
|
---|
62 | char *home_dir;
|
---|
63 | struct passwd *entry;
|
---|
64 |
|
---|
65 | home_dir = (char *)NULL;
|
---|
66 | entry = getpwuid (getuid ());
|
---|
67 | if (entry)
|
---|
68 | home_dir = entry->pw_dir;
|
---|
69 | return (home_dir);
|
---|
70 | }
|
---|