Imported from ../bash-2.03.tar.gz.
This commit is contained in:
parent
bc4cd23ce9
commit
b72432fdcc
191 changed files with 10113 additions and 3553 deletions
|
|
@ -16,10 +16,13 @@ INSTALL_DATA = @INSTALL_DATA@
|
|||
CC = @CC@
|
||||
RANLIB = @RANLIB@
|
||||
AR = @AR@
|
||||
ARFLAGS = @ARFLAGS@
|
||||
RM = rm
|
||||
CP = cp
|
||||
MV = mv
|
||||
|
||||
SHELL = @MAKE_SHELL@
|
||||
|
||||
CFLAGS = @CFLAGS@
|
||||
LOCAL_CFLAGS = @LOCAL_CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
|
|
@ -64,7 +67,7 @@ all: $(LIBRARY_NAME)
|
|||
|
||||
$(LIBRARY_NAME): $(OBJECTS)
|
||||
$(RM) -f $@
|
||||
$(AR) cr $@ $(OBJECTS)
|
||||
$(AR) $(ARFLAGS) $@ $(OBJECTS)
|
||||
-test -n "$(RANLIB)" && $(RANLIB) $@
|
||||
|
||||
documentation: force
|
||||
|
|
|
|||
5
lib/tilde/README
Normal file
5
lib/tilde/README
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
If you're building this separately from bash or the readline library, add
|
||||
$(srcdir)/shell.c to the CSOURCES variable and shell.o to the OBJECTS
|
||||
variable in Makefile.in. (Not that this is very useful without readline
|
||||
or bash.)
|
||||
|
||||
70
lib/tilde/shell.c
Normal file
70
lib/tilde/shell.c
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/* shell.c -- tilde utility functions that are normally provided by
|
||||
bash when readline is linked as part of the shell. */
|
||||
|
||||
/* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Tilde Library.
|
||||
|
||||
The GNU Tilde Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 1, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Tilde Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
#if !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwuid ();
|
||||
#endif /* !HAVE_GETPW_DECLS */
|
||||
|
||||
char *
|
||||
get_env_value (varname)
|
||||
char *varname;
|
||||
{
|
||||
return ((char *)getenv (varname));
|
||||
}
|
||||
|
||||
char *
|
||||
get_home_dir ()
|
||||
{
|
||||
char *home_dir;
|
||||
struct passwd *entry;
|
||||
|
||||
home_dir = (char *)NULL;
|
||||
entry = getpwuid (getuid ());
|
||||
if (entry)
|
||||
home_dir = entry->pw_dir;
|
||||
return (home_dir);
|
||||
}
|
||||
|
|
@ -47,10 +47,6 @@
|
|||
|
||||
#include "tilde.h"
|
||||
|
||||
#ifdef SHELL
|
||||
#include "shell.h"
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwuid (), *getpwnam ();
|
||||
#endif /* !HAVE_GETPW_DECLS */
|
||||
|
|
@ -77,6 +73,12 @@ static char *xmalloc (), *xrealloc ();
|
|||
extern char *xmalloc (), *xrealloc ();
|
||||
#endif /* TEST || STATIC_MALLOC */
|
||||
|
||||
/* If being compiled as part of bash, these will be satisfied from
|
||||
variables.o. If being compiled as part of readline, they will
|
||||
be satisfied from shell.o. */
|
||||
extern char *get_home_dir ();
|
||||
extern char *get_env_value ();
|
||||
|
||||
/* The default value of tilde_additional_prefixes. This is set to
|
||||
whitespace preceding a tilde so that simple programs which do not
|
||||
perform any word separation get desired behaviour. */
|
||||
|
|
@ -171,15 +173,6 @@ tilde_find_suffix (string)
|
|||
return (i);
|
||||
}
|
||||
|
||||
#if !defined (SHELL)
|
||||
static char *
|
||||
get_string_value (varname)
|
||||
char *varname;
|
||||
{
|
||||
return ((char *)getenv (varname));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Return a new string which is the result of tilde expanding STRING. */
|
||||
char *
|
||||
tilde_expand (string)
|
||||
|
|
@ -284,27 +277,6 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_home_dir ()
|
||||
{
|
||||
char *home_dir;
|
||||
|
||||
#ifdef SHELL
|
||||
home_dir = (char *)NULL;
|
||||
if (current_user.home_dir == 0)
|
||||
get_current_user_info ();
|
||||
home_dir = current_user.home_dir;
|
||||
#else
|
||||
struct passwd *entry;
|
||||
|
||||
home_dir = (char *)NULL;
|
||||
entry = getpwuid (getuid ());
|
||||
if (entry)
|
||||
home_dir = entry->pw_dir;
|
||||
#endif
|
||||
return (home_dir);
|
||||
}
|
||||
|
||||
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
|
||||
tilde. If there is no expansion, call tilde_expansion_failure_hook.
|
||||
This always returns a newly-allocated string, never static storage. */
|
||||
|
|
@ -328,7 +300,7 @@ tilde_expand_word (filename)
|
|||
if (filename[1] == '\0' || filename[1] == '/')
|
||||
{
|
||||
/* Prefix $HOME to the rest of the string. */
|
||||
expansion = get_string_value ("HOME");
|
||||
expansion = get_env_value ("HOME");
|
||||
|
||||
/* If there is no HOME variable, look up the directory in
|
||||
the password database. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue