Imported from ../bash-2.04.tar.gz.

This commit is contained in:
Jari Aalto 2000-03-17 21:46:59 +00:00
commit bb70624e96
387 changed files with 28522 additions and 9334 deletions

View file

@ -1,7 +1,22 @@
#
# Simple makefile for the sample loadable builtins
#
#
# Copyright (C) 1996 Free Software Foundation, Inc.
# This program 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 2, or (at your option)
# any later version.
# This program 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.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
# Include some boilerplate Gnu makefile definitions.
prefix = @prefix@
@ -43,7 +58,8 @@ SHOBJ_LIBS = @SHOBJ_LIBS@
SHOBJ_STATUS = @SHOBJ_STATUS@
INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins \
-I$(BUILD_DIR) -I$(BUILD_DIR)/lib -I$(BUILD_DIR)/builtins
-I$(topdir)/include -I$(BUILD_DIR) -I$(BUILD_DIR)/lib \
-I$(BUILD_DIR)/builtins
.c.o:
$(SHOBJ_CC) $(SHOBJ_CFLAGS) $(CFLAGS) $(INC) -c -o $@ $<
@ -165,11 +181,14 @@ pushd: pushd.o
clean:
$(RM) $(ALLPROG) $(OTHERPROG) *.o
-( cd perl && ${MAKE} ${MFLAGS} $@ )
mostlyclean: clean
-( cd perl && ${MAKE} ${MFLAGS} $@ )
distclean maintainer-clean: clean
$(RM) Makefile pushd.c
-( cd perl && ${MAKE} ${MFLAGS} $@ )
print.o: print.c
truefalse.o: truefalse.c

View file

@ -222,16 +222,28 @@ static const struct conf_variable conf_table[] =
#endif
#if defined (_SC_THREADS)
{ "_POSIX_THREADS", SYSCONF, _SC_THREADS },
#endif
#if defined (_SC_THREADS)
{ "_POSIX_THREAD_ATTR_STACKADDR", SYSCONF, _SC_THREAD_ATTR_STACKADDR },
#endif
#if defined (_SC_THREAD_ATTR_STACKSIZE)
{ "_POSIX_THREAD_ATTR_STACKSIZE", SYSCONF, _SC_THREAD_ATTR_STACKSIZE },
#endif
#if defined (_SC_THREAD_PRIORITY_SCHEDULING)
{ "_POSIX_THREAD_PRIORITY_SCHEDULING", SYSCONF, _SC_THREAD_PRIORITY_SCHEDULING },
#endif
#if defined (_SC_THREAD_PRIO_INHERIT)
{ "_POSIX_THREAD_PRIO_INHERIT", SYSCONF, _SC_THREAD_PRIO_INHERIT },
#endif
#if defined (_SC_THREAD_PRIO_PROTECT)
{ "_POSIX_THREAD_PRIO_PROTECT", SYSCONF, _SC_THREAD_PRIO_PROTECT },
#endif
#if defined (_SC_THREAD_PROCESS_SHARED)
{ "_POSIX_THREAD_PROCESS_SHARED", SYSCONF, _SC_THREAD_PROCESS_SHARED },
# if defined (_SC_THREAD_SAFE_FUNCTIONS)
#endif
#if defined (_SC_THREAD_SAFE_FUNCTIONS)
{ "_POSIX_THREAD_SAFE_FUNCTIONS", SYSCONF, _SC_THREAD_SAFE_FUNCTIONS },
# endif
#endif /* _SC_THREADS */
#endif
/* XPG 4.2 Configurable System Variables. */
#if defined (_SC_ATEXIT_MAX)
@ -249,23 +261,44 @@ static const struct conf_variable conf_table[] =
#if defined (_SC_AIO_LISTIO_MAX)
{ "AIO_LISTIO_MAX", SYSCONF, _SC_AIO_LISTIO_MAX },
#endif
#if defined (_SC_AIO_MAX)
{ "AIO_MAX", SYSCONF, _SC_AIO_MAX },
#endif
#if defined (_SC_AIO_PRIO_DELTA_MAX)
{ "AIO_PRIO_DELTA_MAX", SYSCONF, _SC_AIO_PRIO_DELTA_MAX },
#endif
#if defined (_SC_DELAYTIMER_MAX)
{ "DELAYTIMER_MAX", SYSCONF, _SC_DELAYTIMER_MAX },
#endif
#if defined (_SC_GETGR_R_SIZE_MAX)
{ "GETGR_R_SIZE_MAX", SYSCONF, _SC_GETGR_R_SIZE_MAX },
#endif
#if defined (_SC_GETPW_R_SIZE_MAX)
{ "GETPW_R_SIZE_MAX", SYSCONF, _SC_GETPW_R_SIZE_MAX },
#endif
#if defined (_SC_MQ_OPEN_MAX)
{ "MQ_OPEN_MAX", SYSCONF, _SC_MQ_OPEN_MAX },
#endif
#if defined (_SC_MQ_PRIO_MAX)
{ "MQ_PRIO_MAX", SYSCONF, _SC_MQ_PRIO_MAX },
#endif
#if defined (_SC_RTSIG_MAX)
{ "RTSIG_MAX", SYSCONF, _SC_RTSIG_MAX },
#endif
#if defined (_SC_SEM_NSEMS_MAX)
{ "SEM_NSEMS_MAX", SYSCONF, _SC_SEM_NSEMS_MAX },
#endif
#if defined (_SC_SEM_VALUE_MAX)
{ "SEM_VALUE_MAX", SYSCONF, _SC_SEM_VALUE_MAX },
#endif
#if defined (_SC_SIGQUEUE_MAX)
{ "SIGQUEUE_MAX", SYSCONF, _SC_SIGQUEUE_MAX },
#endif
#if defined (_SC_TIMER_MAX)
{ "TIMER_MAX", SYSCONF, _SC_TIMER_MAX },
#endif /* _SC_AIO_LISTIO_MAX */
#endif
#if defined (_SC_LOGIN_NAME_MAX)
{ "LOGIN_NAME_MAX", SYSCONF, _SC_LOGIN_NAME_MAX },
#endif
@ -276,12 +309,18 @@ static const struct conf_variable conf_table[] =
{ "TTY_NAME_MAX", SYSCONF, _SC_TTY_NAME_MAX },
#endif
#if defined (_SC_PTHREAD_DESTRUCTOR_ITERATIONS)
#if defined (_SC_THREAD_DESTRUCTOR_ITERATIONS)
{ "PTHREAD_DESTRUCTOR_ITERATIONS", SYSCONF, _SC_THREAD_DESTRUCTOR_ITERATIONS },
#endif
#if defined (_SC_THREAD_KEYS_MAX)
{ "PTHREAD_KEYS_MAX", SYSCONF, _SC_THREAD_KEYS_MAX },
#endif
#if defined (_SC_THREAD_STACK_MIN)
{ "PTHREAD_STACK_MIN", SYSCONF, _SC_THREAD_STACK_MIN },
#endif
#if defined (_SC_THREAD_THREADS_MAX)
{ "PTHREAD_THREADS_MAX", SYSCONF, _SC_THREAD_THREADS_MAX },
#endif /* _SC_PTHREAD_DESTRUCTOR_ITERATIONS */
#endif
/* XPG 4.2 Optional Facility Configuration Values */
#if defined (_SC_XOPEN_UNIX)

View file

@ -0,0 +1,97 @@
#
# Makefile for builtin perl interpreter
#
#
# Copyright (C) 1998 Free Software Foundation, Inc.
# This program 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 2, or (at your option)
# any later version.
# This program 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.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
# Include some boilerplate Gnu makefile definitions.
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
infodir = @infodir@
includedir = @includedir@
topdir = @top_srcdir@
BUILD_DIR = @BUILD_DIR@
srcdir = @srcdir@
VPATH = .:@srcdir@
@SET_MAKE@
CC = @CC@
RM = rm -f
SHELL = @MAKE_SHELL@
PERL5 = perl5
CFLAGS = @CFLAGS@
#
# These values are generated for configure by ${topdir}/support/shobj-conf.
# If your system is not supported by that script, but includes facilities for
# dynamic loading of shared objects, please update the script and send the
# changes to bash-maintainers@gnu.org.
#
SHOBJ_CC = @SHOBJ_CC@
SHOBJ_CFLAGS = @SHOBJ_CFLAGS@
SHOBJ_LD = @SHOBJ_LD@
SHOBJ_LDFLAGS = @SHOBJ_LDFLAGS@
SHOBJ_XLDFLAGS = @SHOBJ_XLDFLAGS@
SHOBJ_LIBS = @SHOBJ_LIBS@
SHOBJ_STATUS = @SHOBJ_STATUS@
# Values used for compiling the perl files
PERL_LDOPTS = `${PERL5} -MExtUtils::Embed -e ldopts`
PERL_CFLAGS = ${CCFLAGS} `${PERL5} -MExtUtils::Embed -e ccopts`
SRC = bperl.c iperl.c perlxsi.c
OBJ = bperl.o iperl.o perlxsi.o
BUILTIN = bperl5
INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins \
-I$(topdir)/include -I$(BUILD_DIR) -I$(BUILD_DIR)/lib \
-I$(BUILD_DIR)/builtins
${BUILTIN}: ${OBJ}
${RM} $@
${SHOBJ_LD} ${SHOBJ_LDFLAGS} ${SHOBJ_XLDFLAGS} -o $@ ${OBJ} ${PERL_LDOPTS} ${SHOBJ_LIBS}
bperl.o: bperl.c
${RM} $@
$(SHOBJ_CC) $(SHOBJ_CFLAGS) $(CFLAGS) $(INC) -c -o $@ ${srcdir}/bperl.c
iperl.o: iperl.c
${RM} $@
$(SHOBJ_CC) ${SHOBJ_CFLAGS} $(PERL_CFLAGS) -c -o $@ ${srcdir}/iperl.c
perlxsi.c:
${PERL5} -MExtUtils::Embed -e xsinit -- -o $@
perlxsi.o: perlxsi.c
${RM} $@
${SHOBJ_CC} ${SHOBJ_CFLAGS} $(PERL_CFLAGS) -c -o $@ perlxsi.c
clean mostlyclean:
${RM} ${OBJ}
${RM} ${BUILTIN}
distclean maintainer-clean: clean
${RM} perlxsi.c

View file

@ -0,0 +1,6 @@
This illustrates how to build a perl interpreter into bash. It's not
especially useful; more a proof of concept (it provides none of the
bash internals to the perl interpreter, for example).
This *may* require adding "-rpath /path/to/perl/CORE" and -lperl options
when compiling bash itself.

View file

@ -0,0 +1,46 @@
/*
* perl builtin
*/
#include <config.h>
#include <fcntl.h>
#include <errno.h>
#include "builtins.h"
#include "shell.h"
#ifndef errno
extern int errno;
#endif
extern char **make_builtin_argv ();
extern char **export_env;
extern int perl_main();
bperl_builtin(list)
WORD_LIST *list;
{
char **v;
int c, r;
v = make_builtin_argv(list, &c);
r = perl_main(c, v, export_env);
free(v);
return r;
}
char *bperl_doc[] = {
"An interface to a perl5 interpreter.",
(char *)0
};
struct builtin bperl_struct = {
"bperl",
bperl_builtin,
BUILTIN_ENABLED,
bperl_doc,
"bperl [perl options] [file ...]",
0
};

View file

@ -0,0 +1,24 @@
#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */
extern void xs_init _((void));
static PerlInterpreter *iperl; /*** The Perl interpreter ***/
int
perl_main(int argc, char **argv, char **env)
{
int r;
iperl = perl_alloc();
perl_construct(iperl);
perl_parse(iperl, xs_init, argc, argv, (char **)NULL);
r = perl_run(iperl);
PerlIO_flush(PerlIO_stdout());
PerlIO_flush(PerlIO_stderr());
perl_destruct(iperl);
perl_free(iperl);
return (r);
}

View file

@ -1,3 +1,7 @@
/*
* print -- loadable ksh-93 style print builtin
*/
#include "bashtypes.h"
#include <errno.h>
@ -19,8 +23,6 @@ static int printargs ();
static FILE *ofp;
extern char *ansicstr ();
extern char *this_command_name;
static char *print_doc[] = {
@ -150,7 +152,7 @@ printargs (list, ofp)
for (sawc = 0, l = list; l; l = l->next)
{
ostr = ansicstr (l->word->word, strlen (l->word->word), &sawc, (int *)0);
ostr = ansicstr (l->word->word, strlen (l->word->word), 0, &sawc, (int *)0);
fprintf (ofp, "%s", ostr);
free (ostr);
if (sawc)
@ -160,4 +162,3 @@ printargs (list, ofp)
}
return (1);
}