ash: fix for buglet in DEBUG code (Nguyen Thai Ngoc Duy <pclouds@gmail.com>)
This commit is contained in:
parent
153cd695e4
commit
40ba9984fd
31
shell/ash.c
31
shell/ash.c
@ -840,23 +840,24 @@ shcmd(union node *cmd, FILE *fp)
|
|||||||
|
|
||||||
first = 1;
|
first = 1;
|
||||||
for (np = cmd->ncmd.args; np; np = np->narg.next) {
|
for (np = cmd->ncmd.args; np; np = np->narg.next) {
|
||||||
if (! first)
|
if (!first)
|
||||||
putchar(' ');
|
putc(' ', fp);
|
||||||
sharg(np, fp);
|
sharg(np, fp);
|
||||||
first = 0;
|
first = 0;
|
||||||
}
|
}
|
||||||
for (np = cmd->ncmd.redirect; np; np = np->nfile.next) {
|
for (np = cmd->ncmd.redirect; np; np = np->nfile.next) {
|
||||||
if (! first)
|
if (!first)
|
||||||
putchar(' ');
|
putc(' ', fp);
|
||||||
|
dftfd = 0;
|
||||||
switch (np->nfile.type) {
|
switch (np->nfile.type) {
|
||||||
case NTO: s = ">"; dftfd = 1; break;
|
case NTO: s = ">>"+1; dftfd = 1; break;
|
||||||
case NCLOBBER: s = ">|"; dftfd = 1; break;
|
case NCLOBBER: s = ">|"; dftfd = 1; break;
|
||||||
case NAPPEND: s = ">>"; dftfd = 1; break;
|
case NAPPEND: s = ">>"; dftfd = 1; break;
|
||||||
case NTOFD: s = ">&"; dftfd = 1; break;
|
case NTOFD: s = ">&"; dftfd = 1; break;
|
||||||
case NFROM: s = "<"; dftfd = 0; break;
|
case NFROM: s = "<"; break;
|
||||||
case NFROMFD: s = "<&"; dftfd = 0; break;
|
case NFROMFD: s = "<&"; break;
|
||||||
case NFROMTO: s = "<>"; dftfd = 0; break;
|
case NFROMTO: s = "<>"; break;
|
||||||
default: s = "*error*"; dftfd = 0; break;
|
default: s = "*error*"; break;
|
||||||
}
|
}
|
||||||
if (np->nfile.fd != dftfd)
|
if (np->nfile.fd != dftfd)
|
||||||
fprintf(fp, "%d", np->nfile.fd);
|
fprintf(fp, "%d", np->nfile.fd);
|
||||||
@ -3774,7 +3775,7 @@ showjob(FILE *out, struct job *jp, int mode)
|
|||||||
struct procstat *ps;
|
struct procstat *ps;
|
||||||
struct procstat *psend;
|
struct procstat *psend;
|
||||||
int col;
|
int col;
|
||||||
int indent;
|
int indent_col;
|
||||||
char s[80];
|
char s[80];
|
||||||
|
|
||||||
ps = jp->ps;
|
ps = jp->ps;
|
||||||
@ -3786,7 +3787,7 @@ showjob(FILE *out, struct job *jp, int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
col = fmtstr(s, 16, "[%d] ", jobno(jp));
|
col = fmtstr(s, 16, "[%d] ", jobno(jp));
|
||||||
indent = col;
|
indent_col = col;
|
||||||
|
|
||||||
if (jp == curjob)
|
if (jp == curjob)
|
||||||
s[col - 2] = '+';
|
s[col - 2] = '+';
|
||||||
@ -3812,7 +3813,7 @@ showjob(FILE *out, struct job *jp, int mode)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
/* for each process */
|
/* for each process */
|
||||||
col = fmtstr(s, 48, " |\n%*c%d ", indent, ' ', ps->pid) - 3;
|
col = fmtstr(s, 48, " |\n%*c%d ", indent_col, ' ', ps->pid) - 3;
|
||||||
start:
|
start:
|
||||||
fprintf(out, "%s%*c%s",
|
fprintf(out, "%s%*c%s",
|
||||||
s, 33 - col >= 0 ? 33 - col : 0, ' ', ps->cmd
|
s, 33 - col >= 0 ? 33 - col : 0, ' ', ps->cmd
|
||||||
|
Loading…
x
Reference in New Issue
Block a user