summaryrefslogtreecommitdiff
path: root/appl/cmd/sh
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2008-10-22 21:17:47 +0000
committerCharles.Forsyth <devnull@localhost>2008-10-22 21:17:47 +0000
commit1bc0e0d583f076e6dd04193c4b38c6a1e8907ba9 (patch)
tree30833f3701fe7bdca39291bee06b48a92555461c /appl/cmd/sh
parentbb0454063029bcd36bb713dc95bbce4c4fa43510 (diff)
20081022-2217
Diffstat (limited to 'appl/cmd/sh')
-rw-r--r--appl/cmd/sh/sh.b22
-rw-r--r--appl/cmd/sh/sh.y22
2 files changed, 32 insertions, 12 deletions
diff --git a/appl/cmd/sh/sh.b b/appl/cmd/sh/sh.b
index 05a8227a..7cd69cb0 100644
--- a/appl/cmd/sh/sh.b
+++ b/appl/cmd/sh/sh.b
@@ -221,7 +221,7 @@ system(drawctxt: ref Draw->Context, cmd: string): string
return Context.new(drawctxt).run(ref Listnode(n, nil) :: nil, 0);
} exception e {
"fail:*" =>
- return e[5:];
+ return failurestatus(e);
}
}
@@ -232,7 +232,7 @@ run(drawctxt: ref Draw->Context, argv: list of string): string
return Context.new(drawctxt).run(stringlist2list(argv), 0);
} exception e {
"fail:*" =>
- return e[5:];
+ return failurestatus(e);
}
}
@@ -294,7 +294,7 @@ runfile(ctxt: ref Context, fd: ref Sys->FD, path: string, args: list of ref List
laststatus = walk(ctxt, n, 0);
} exception e2 {
"fail:*" =>
- laststatus = e2[5:];
+ laststatus = failurestatus(e2);
}
} else
laststatus = walk(ctxt, n, 0);
@@ -792,7 +792,7 @@ runexternal(ctxt: ref Context, args: list of ref Listnode, last: int): string
EPIPE =>
return EPIPE;
"fail:*" =>
- return e[5:];
+ return failurestatus(e);
}
}
extstart := chan of int;
@@ -819,6 +819,16 @@ runexternal(ctxt: ref Context, args: list of ref Listnode, last: int): string
return err;
}
+failurestatus(e: string): string
+{
+ s := e[5:];
+ while(s != nil && (s[0] == ' ' || s[0] == '\t'))
+ s = s[1:];
+ if(s != nil)
+ return s;
+ return "failed";
+}
+
runhashpling(ctxt: ref Context, fd: ref Sys->FD,
path: string, argv: list of ref Listnode, last: int): string
{
@@ -1020,7 +1030,7 @@ waitfor(ctxt: ref Context, pids: list of int): string
(who, line, s) := parsewaitstatus(ctxt, string buf[0:n]);
if (s != nil) {
if (len s >= 5 && s[0:5] == "fail:")
- s = s[5:];
+ s = failurestatus(s);
else
diagnostic(ctxt, line);
}
@@ -1911,7 +1921,7 @@ builtin_run(ctxt: ref Context, args: list of ref Listnode, nil: int): string
} exception e {
"fail:*" =>
ctxt.pop();
- return e[5:];
+ return failurestatus(e);
}
}
diff --git a/appl/cmd/sh/sh.y b/appl/cmd/sh/sh.y
index 44984a1b..f6b27c22 100644
--- a/appl/cmd/sh/sh.y
+++ b/appl/cmd/sh/sh.y
@@ -286,7 +286,7 @@ system(drawctxt: ref Draw->Context, cmd: string): string
return Context.new(drawctxt).run(ref Listnode(n, nil) :: nil, 0);
} exception e {
"fail:*" =>
- return e[5:];
+ return failurestatus(e);
}
}
@@ -297,7 +297,7 @@ run(drawctxt: ref Draw->Context, argv: list of string): string
return Context.new(drawctxt).run(stringlist2list(argv), 0);
} exception e {
"fail:*" =>
- return e[5:];
+ return failurestatus(e);
}
}
@@ -362,7 +362,7 @@ runfile(ctxt: ref Context, fd: ref Sys->FD, path: string, args: list of ref List
laststatus = walk(ctxt, n, 0);
} exception e2 {
"fail:*" =>
- laststatus = e2[5:];
+ laststatus = failurestatus(e2);
}
} else
laststatus = walk(ctxt, n, 0);
@@ -884,7 +884,7 @@ runexternal(ctxt: ref Context, args: list of ref Listnode, last: int): string
EPIPE =>
return EPIPE;
"fail:*" =>
- return e[5:];
+ return failurestatus(e);
}
}
extstart := chan of int;
@@ -911,6 +911,16 @@ runexternal(ctxt: ref Context, args: list of ref Listnode, last: int): string
return err;
}
+failurestatus(e: string): string
+{
+ s := e[5:];
+ while(s != nil && (s[0] == ' ' || s[0] == '\t'))
+ s = s[1:];
+ if(s != nil)
+ return s;
+ return "failed";
+}
+
runhashpling(ctxt: ref Context, fd: ref Sys->FD,
path: string, argv: list of ref Listnode, last: int): string
{
@@ -1119,7 +1129,7 @@ waitfor(ctxt: ref Context, pids: list of int): string
(who, line, s) := parsewaitstatus(ctxt, string buf[0:n]);
if (s != nil) {
if (len s >= 5 && s[0:5] == "fail:")
- s = s[5:];
+ s = failurestatus(s);
else
diagnostic(ctxt, line);
}
@@ -2049,7 +2059,7 @@ builtin_run(ctxt: ref Context, args: list of ref Listnode, nil: int): string
} exception e {
"fail:*" =>
ctxt.pop();
- return e[5:];
+ return failurestatus(e);
}
}