add back in support for building w/o obj dir. also, add NO_HISTORY

define, which (if you invoke mkbuiltins properly) gets you a sh w/o
history of command line editing (for floppy sh).
This commit is contained in:
cgd 1994-05-14 22:20:04 +00:00
parent 1e55974f48
commit e3c63ad9f3
8 changed files with 39 additions and 9 deletions

View File

@ -21,7 +21,7 @@ token.def: mktokens
sh ${.CURDIR}/mktokens
builtins.h builtins.c: ${.CURDIR}/mkbuiltins ${.CURDIR}/builtins
cd ${.CURDIR}; sh mkbuiltins
cd ${.CURDIR}; sh mkbuiltins ${.OBJDIR}
init.c: mkinit ${SRCS}
./mkinit '${CC} -c ${CFLAGS} init.c' ${.ALLSRC}

View File

@ -39,7 +39,9 @@
#
# This file lists all the builtin commands. The first column is the name
# of a C routine. The -j flag, if present, specifies that this command
# is to be excluded from systems without job control. The rest of the line
# is to be excluded from systems without job control, and the -h flag,
# if present specifies that this command is to be excluded from systems
# based on the NO_HISTORY compile-time symbol. The rest of the line
# specifies the command name or names used to run the command. The entry
# for bltincmd, which is run when the user does not specify a command, must
# come first.
@ -65,7 +67,7 @@ expcmd exp let
exportcmd export readonly
#exprcmd expr test [
falsecmd false
histcmd fc
histcmd -h fc
fgcmd -j fg
getoptscmd getopts
hashcmd hash

View File

@ -39,7 +39,9 @@
#
# This file lists all the builtin commands. The first column is the name
# of a C routine. The -j flag, if present, specifies that this command
# is to be excluded from systems without job control. The rest of the line
# is to be excluded from systems without job control, and the -h flag,
# if present specifies that this command is to be excluded from systems
# based on the NO_HISTORY compile-time symbol. The rest of the line
# specifies the command name or names used to run the command. The entry
# for bltincmd, which is run when the user does not specify a command, must
# come first.
@ -65,7 +67,7 @@ expcmd exp let
exportcmd export readonly
#exprcmd expr test [
falsecmd false
histcmd fc
histcmd -h fc
fgcmd -j fg
getoptscmd getopts
hashcmd hash

View File

@ -198,7 +198,9 @@ evaltree(n, flags)
exitstatus = 0;
goto out;
}
#ifndef NO_HISTORY
displayhist = 1; /* show history substitutions done with fc */
#endif
TRACE(("evaltree(0x%x: %d) called\n", (int)n, n->type));
switch (n->type) {
case NSEMI:
@ -788,7 +790,9 @@ cmddone:
if (e != EXERROR || cmdentry.u.index == BLTINCMD
|| cmdentry.u.index == DOTCMD
|| cmdentry.u.index == EVALCMD
#ifndef NO_HISTORY
|| cmdentry.u.index == HISTCMD
#endif
|| cmdentry.u.index == EXECCMD)
exraise(e);
FORCEINTON;

View File

@ -183,7 +183,9 @@ preadbuffer() {
register char *p, *q;
register int i;
register int something;
#ifndef NO_HISTORY
extern EditLine *el;
#endif
if (parsefile->strpush) {
popstring();
@ -195,6 +197,7 @@ preadbuffer() {
flushout(&output);
flushout(&errout);
retry:
#ifndef NO_HISTORY
p = parsenextc = parsefile->buf;
if (parsefile->fd == 0 && el) {
const char *rl_cp;
@ -209,9 +212,12 @@ retry:
i = len;
} else {
#endif
regular_read:
i = read(parsefile->fd, p, BUFSIZ - 1);
#ifndef NO_HISTORY
}
#endif
eof:
if (i <= 0) {
if (i < 0) {
@ -261,12 +267,14 @@ eof:
parsenleft = q - parsefile->buf - 1;
done:
#ifndef NO_HISTORY
if (parsefile->fd == 0 && hist && something) {
INTOFF;
history(hist, whichprompt == 1 ? H_ENTER : H_ADD,
parsefile->buf);
INTON;
}
#endif
if (vflag) {
/*
* This isn't right. Most shells coordinate it with

View File

@ -41,7 +41,13 @@ havejobs=0
if grep '^#define JOBS[ ]*1' shell.h > /dev/null
then havejobs=1
fi
exec > obj/builtins.c
havehist=1
if [ "$1" = "-h" ]; then
havehist=0
shift
fi
objdir=$1
exec > ${objdir}/builtins.c
cat <<\!
/*
* This file was generated by the mkbuiltins program.
@ -51,8 +57,8 @@ cat <<\!
#include "builtins.h"
!
awk '/^[^#]/ {if('$havejobs' || $2 != "-j") print $0}' builtins |
sed 's/-j//' > $temp
awk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \
print $0}' builtins | sed 's/-j//' > $temp
awk '{ printf "int %s();\n", $1}' $temp
echo '
int (*const builtinfunc[])() = {'
@ -66,7 +72,7 @@ awk '{ for (i = 2 ; i <= NF ; i++) {
echo ' NULL, 0
};'
exec > obj/builtins.h
exec > ${objdir}/builtins.h
cat <<\!
/*
* This file was generated by the mkbuiltins program.

View File

@ -117,7 +117,9 @@ procargs(argc, argv)
optschanged() {
setinteractive(iflag);
#ifndef NO_HISTORY
histedit();
#endif
setjobctl(mflag);
}

View File

@ -71,7 +71,9 @@ struct varinit {
#if ATTY
struct var vatty;
#endif
#ifndef NO_HISTORY
struct var vhistsize;
#endif
struct var vifs;
struct var vmail;
struct var vmpath;
@ -87,7 +89,9 @@ const struct varinit varinit[] = {
#if ATTY
{&vatty, VSTRFIXED|VTEXTFIXED|VUNSET, "ATTY="},
#endif
#ifndef NO_HISTORY
{&vhistsize, VSTRFIXED|VTEXTFIXED|VUNSET, "HISTSIZE="},
#endif
{&vifs, VSTRFIXED|VTEXTFIXED, "IFS= \t\n"},
{&vmail, VSTRFIXED|VTEXTFIXED|VUNSET, "MAIL="},
{&vmpath, VSTRFIXED|VTEXTFIXED|VUNSET, "MAILPATH="},
@ -239,8 +243,10 @@ setvareq(s, flags)
vp->text = s;
if (vp == &vmpath || (vp == &vmail && ! mpathset()))
chkmail(1);
#ifndef NO_HISTORY
if (vp == &vhistsize)
sethistsize();
#endif
INTON;
return;
}