diff options
author | John Ankarström <john@ankarstrom.se> | 2021-06-07 16:36:05 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-06-08 01:50:54 +0200 |
commit | 7aaf4f2423e2bcabce508e91255de673db50b728 (patch) | |
tree | cfdfc247185d7a97fce6f96110fb964f00b766fe /main.c | |
parent | 60b250c267e9ce69f428fd2f0f56a4b1a54f2004 (diff) | |
download | ksh-master.tar.gz |
ksh will write lines to write-file containing information about
the status of the shell:
after prompt: empty line
after command entry: "cmd" followed by command
after cwd change: "cwd" followed by new cwd
fg is handled specially, printing a new "cmd" line with the original
command associated with the job.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -278,6 +278,9 @@ main(int argc, char *argv[]) /* Set this before parsing arguments */ Flag(FPRIVILEGED) = getuid() != ksheuid || getgid() != getegid(); + /* set before parse_args */ + writefd = 0; + /* this to note if monitor is set on command line (see below) */ Flag(FMONITOR) = 127; argi = parse_args(argv, OF_CMDLINE, (int *) 0); @@ -286,6 +289,10 @@ main(int argc, char *argv[]) /* NOTREACHED */ } + /* print initial cwd */ + if (writefd) + dprintf(writefd, "cwd%s\n", current_wd); + if (Flag(FCOMMAND)) { s = pushs(SSTRING, ATEMP); if (!(s->start = s->str = argv[argi++])) @@ -578,7 +585,12 @@ shell(s, toplevel) set_prompt(PS1, s); } + if (interactive && writefd) + dprintf(writefd, "\n"); t = compile(s); + if (interactive && writefd && s->start[0] != '\n') + dprintf(writefd, "cmd%s", s->start); + if (t != NULL && t->type == TEOF) { if (wastty && Flag(FIGNOREEOF) && --attempts > 0) { shellf("Use `exit' to leave ksh\n"); |