summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
665ce89)
implement history save and restore.
SCCS-vsn: bin/csh/csh.c 4.4
SCCS-vsn: bin/csh/csh.h 4.2
SCCS-vsn: bin/csh/hist.c 4.3
*/
char *pathlist[] = { ".", "/usr/ucb", "/bin", "/usr/bin", 0 };
*/
char *pathlist[] = { ".", "/usr/ucb", "/bin", "/usr/bin", 0 };
-char *dumphist[] = { "history", "-c", "+1000" };
+char *dumphist[] = { "history", "-h", 0 };
+char *loadhist[] = { "source", "-h", "~/.history", 0 };
char HIST = '!';
char HISTSUB = '^';
bool nofile;
char HIST = '!';
char HISTSUB = '^';
bool nofile;
sigset(SIGINT, parintr); /* ... restore */
parterm = signal(SIGTERM, SIG_IGN); /* parents terminability */
signal(SIGTERM, parterm); /* ... restore */
sigset(SIGINT, parintr); /* ... restore */
parterm = signal(SIGTERM, SIG_IGN); /* parents terminability */
signal(SIGTERM, parterm); /* ... restore */
+ if (loginsh)
+ signal(SIGHUP, phup); /* exit processing on HUP */
/*
* Process the arguments.
/*
* Process the arguments.
if (ioctl(f, TIOCGETD, &oldisc) != 0)
goto notty;
if (oldisc != NTTYDISC) {
if (ioctl(f, TIOCGETD, &oldisc) != 0)
goto notty;
if (oldisc != NTTYDISC) {
- printf("Switching to new tty driver...\n");
+#ifdef DEBUG
+ printf("Switching to new tty driver...\n");
+#endif DEBUG
ldisc = NTTYDISC;
ioctl(f, TIOCSETD, &ldisc);
} else
ldisc = NTTYDISC;
ioctl(f, TIOCSETD, &ldisc);
} else
srccat(value("home"), "/.cshrc");
if (!fast && !arginp && !onelflg)
dohash();
srccat(value("home"), "/.cshrc");
if (!fast && !arginp && !onelflg)
dohash();
if (loginsh) {
srccat(value("home"), "/.login");
if (loginsh) {
srccat(value("home"), "/.login");
- enterhist = 1;
- srccat(value("home"), "/.history");
- enterhist = 0;
setpgrp(0, opgrp);
ioctl(FSHTTY, TIOCSPGRP, &opgrp);
if (oldisc != -1 && oldisc != NTTYDISC) {
setpgrp(0, opgrp);
ioctl(FSHTTY, TIOCSPGRP, &opgrp);
if (oldisc != -1 && oldisc != NTTYDISC) {
printf("\nReverting to old tty driver...\n");
printf("\nReverting to old tty driver...\n");
ioctl(FSHTTY, TIOCSETD, &oldisc);
}
}
ioctl(FSHTTY, TIOCSETD, &oldisc);
}
}
/* ioctl(unit, FIOCLEX, NULL); */
xfree(ep);
#ifdef INGRES
/* ioctl(unit, FIOCLEX, NULL); */
xfree(ep);
#ifdef INGRES
* Source to a unit. If onlyown it must be our file or our group or
* we don't chance it. This occurs on ".cshrc"s and the like.
*/
* Source to a unit. If onlyown it must be our file or our group or
* we don't chance it. This occurs on ".cshrc"s and the like.
*/
+srcunit(unit, onlyown, hflg)
register int unit;
bool onlyown;
register int unit;
bool onlyown;
{
/* We have to push down a lot of state here */
/* All this could go into a structure */
{
/* We have to push down a lot of state here */
/* All this could go into a structure */
char *ogointr = gointr, *oarginp = arginp;
char *oevalp = evalp, **oevalvec = evalvec;
int oonelflg = onelflg;
char *ogointr = gointr, *oarginp = arginp;
char *oevalp = evalp, **oevalvec = evalvec;
int oonelflg = onelflg;
+ bool oenterhist = enterhist;
+ char OHIST = HIST;
#ifdef TELL
bool otell = cantell;
#endif
#ifdef TELL
bool otell = cantell;
#endif
oSHIN = SHIN, SHIN = unit, arginp = 0, onelflg = 0;
intty = isatty(SHIN), whyles = 0, gointr = 0;
evalvec = 0; evalp = 0;
oSHIN = SHIN, SHIN = unit, arginp = 0, onelflg = 0;
intty = isatty(SHIN), whyles = 0, gointr = 0;
evalvec = 0; evalp = 0;
+ enterhist = hflg;
+ if (enterhist)
+ HIST = '\0';
/*
* Now if we are allowing commands to be interrupted,
* we let ourselves be interrupted.
/*
* Now if we are allowing commands to be interrupted,
* we let ourselves be interrupted.
arginp = oarginp, onelflg = oonelflg;
evalp = oevalp, evalvec = oevalvec;
intty = oldintty, whyles = oldwhyl, gointr = ogointr;
arginp = oarginp, onelflg = oonelflg;
evalp = oevalp, evalvec = oevalvec;
intty = oldintty, whyles = oldwhyl, gointr = ogointr;
+ enterhist = oenterhist;
+ HIST = OHIST;
#ifdef TELL
cantell = otell;
#endif
#ifdef TELL
cantell = otell;
#endif
{
char buf[BUFSIZ];
int fp, ftmp, oldidfds;
{
char buf[BUFSIZ];
int fp, ftmp, oldidfds;
strcpy(buf, value("home"));
strcat(buf, "/.history");
fp = creat(buf, 0777);
strcpy(buf, value("home"));
strcat(buf, "/.history");
fp = creat(buf, 0777);
SHOUT = ftmp;
didfds = oldidfds;
}
SHOUT = ftmp;
didfds = oldidfds;
}
+ }
+}
+
+goodbye()
+{
+ if (loginsh) {
signal(SIGQUIT, SIG_IGN);
sigset(SIGINT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
sigset(SIGINT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
if (adrof("home"))
srccat(value("home"), "/.logout");
}
if (adrof("home"))
srccat(value("home"), "/.logout");
}
exit(getn(value("status")));
}
exit(getn(value("status")));
}
+/*
+ * in the event of a HUP we want to save the history
+ */
+phup()
+{
+ rechist();
+ exit(1);
+}
+
char *jobargv[2] = { "jobs", 0 };
/*
* Catch an interrupt, e.g. during lexical input.
char *jobargv[2] = { "jobs", 0 };
/*
* Catch an interrupt, e.g. during lexical input.
* Echo not only on VERBOSE, but also with history expansion.
* If there is a lexical error then we forego history echo.
*/
* Echo not only on VERBOSE, but also with history expansion.
* If there is a lexical error then we forego history echo.
*/
- if (lex(¶ml) && !err && intty || adrof("verbose")) {
+ if (lex(¶ml) && !err && intty ||
+ adrof("verbose")) {
haderr = 1;
prlex(¶ml);
haderr = 0;
haderr = 1;
prlex(¶ml);
haderr = 0;
- * Print lexical error messages.
+ * Print lexical error messages, except when sourcing
+ * history lists.
{
register char *f;
register int u;
{
register char *f;
register int u;
+ bool hflg = 0;
+ char buf[BUFSIZ];
+ if (*t && eq(*t, "-h")) {
+ t++;
+ hflg++;
+ }
+ strcpy(buf, *t);
+ f = globone(buf);
u = dmove(open(f, 0), -1);
xfree(f);
u = dmove(open(f, 0), -1);
xfree(f);
#include "sh.local.h"
#ifdef VMUNIX
#include "sh.local.h"
#ifdef VMUNIX
struct biltins *isbfunc();
char **glob();
char *operate();
struct biltins *isbfunc();
char **glob();
char *operate();
int pintr();
int pchild();
char *putn();
int pintr();
int pchild();
char *putn();
- int n, rflg = 0, cflg = 0;
-
+ int n, rflg = 0, hflg = 0;
if (getn(value("history")) == 0)
return;
if (setintr)
sigrelse(SIGINT);
vp++;
while (*vp[0] == '-') {
if (getn(value("history")) == 0)
return;
if (setintr)
sigrelse(SIGINT);
vp++;
while (*vp[0] == '-') {
- if (*vp && eq(*vp, "-c")) {
- cflg++;
+ if (*vp && eq(*vp, "-h")) {
+ hflg++;
vp++;
}
if (*vp && eq(*vp, "-r")) {
vp++;
}
if (*vp && eq(*vp, "-r")) {
}
if (*vp)
n = getn(*vp);
}
if (*vp)
n = getn(*vp);
- else
- n = 1000;
- dohist1(Histlist.Hnext, &n, rflg, cflg);
+ else {
+ n = getn(value("history"));
+ }
+ dohist1(Histlist.Hnext, &n, rflg, hflg);
-dohist1(hp, np, rflg, cflg)
+dohist1(hp, np, rflg, hflg)
{
bool print = (*np) > 0;
top:
{
bool print = (*np) > 0;
top:
(*np)--;
hp->Href++;
if (rflg == 0) {
(*np)--;
hp->Href++;
if (rflg == 0) {
- dohist1(hp->Hnext, np, rflg, cflg);
+ dohist1(hp->Hnext, np, rflg, hflg);
hp = hp->Hnext;
goto top;
}
hp = hp->Hnext;
goto top;
}
register struct Hist *hp;
register struct Hist *hp;
printf("%6d\t", hp->Hnum);
prlex(&hp->Hlex);
}
printf("%6d\t", hp->Hnum);
prlex(&hp->Hlex);
}