1 /* shell.c -- readline utility functions that are normally provided by
2 bash when readline is linked as part of the shell. */
4 /* Copyright (C) 1997 Free Software Foundation, Inc.
6 This file is part of the GNU Readline Library, a library for
7 reading lines of text with interactive input and history editing.
9 The GNU Readline Library is free software; you can redistribute it
10 and/or modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 1, or
12 (at your option) any later version.
14 The GNU Readline Library is distributed in the hope that it will be
15 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
16 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 The GNU General Public License is often shipped with GNU software, and
20 is generally kept in a file called COPYING or LICENSE. If you do not
21 have a copy of the license, write to the Free Software Foundation,
22 675 Mass Ave, Cambridge, MA 02139, USA. */
23 #define READLINE_LIBRARY
25 #if defined (HAVE_CONFIG_H)
29 #include <sys/types.h>
32 #if defined (HAVE_UNISTD_H)
34 #endif /* HAVE_UNISTD_H */
36 #if defined (HAVE_STDLIB_H)
39 # include "ansi_stdlib.h"
40 #endif /* HAVE_STDLIB_H */
42 #if defined (HAVE_STRING_H)
46 #endif /* !HAVE_STRING_H */
50 #if !defined (HAVE_GETPW_DECLS)
51 extern struct passwd
*getpwuid ();
52 #endif /* !HAVE_GETPW_DECLS */
54 extern char *xmalloc ();
56 /* All of these functions are resolved from bash if we are linking readline
59 /* Does shell-like quoting using single quotes. */
67 result
= (char *)xmalloc (3 + (3 * strlen (string
)));
71 for (s
= string
; s
&& (c
= *s
); s
++)
77 *r
++ = '\\'; /* insert escaped single quote */
79 *r
++ = '\''; /* start new quoted string */
89 /* Set the environment variables LINES and COLUMNS to lines and cols,
92 set_lines_and_columns (lines
, cols
)
97 #if defined (HAVE_PUTENV)
99 sprintf (b
, "LINES=%d", lines
);
102 sprintf (b
, "COLUMNS=%d", cols
);
104 #else /* !HAVE_PUTENV */
105 # if defined (HAVE_SETENV)
107 sprintf (b
, "%d", lines
);
108 setenv ("LINES", b
, 1);
110 sprintf (b
, "%d", cols
);
111 setenv ("COLUMNS", b
, 1);
112 # endif /* HAVE_SETENV */
113 #endif /* !HAVE_PUTENV */
117 get_env_value (varname
)
120 return ((char *)getenv (varname
));
127 struct passwd
*entry
;
129 home_dir
= (char *)NULL
;
130 entry
= getpwuid (getuid ());
132 home_dir
= entry
->pw_dir
;
This page took 0.032397 seconds and 4 git commands to generate.