summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2009-04-18 12:27:30 +0000
committerCharles.Forsyth <devnull@localhost>2009-04-18 12:27:30 +0000
commit64047388f80c4b4daa68a5568c2b8a4ad5d63816 (patch)
treeffe73fd8eff161d53253c9ecae2b325a861e0246
parent26a94bf68dec1d25fba9f417b7846da9f52dbfe1 (diff)
20090418-1326
-rw-r--r--appl/cmd/m4.b25
-rw-r--r--dis/m4.disbin11662 -> 11974 bytes
-rw-r--r--man/1/m413
3 files changed, 33 insertions, 5 deletions
diff --git a/appl/cmd/m4.b b/appl/cmd/m4.b
index 6d5d9864..9315bf55 100644
--- a/appl/cmd/m4.b
+++ b/appl/cmd/m4.b
@@ -9,6 +9,8 @@ include "bufio.m";
bufio: Bufio;
Iobuf: import bufio;
+include "sh.m";
+
include "arg.m";
M4: module
@@ -50,6 +52,7 @@ rquote := '\'';
initcom := "#";
endcom := "\n";
bout: ref Iobuf;
+sh: Sh;
init(nil: ref Draw->Context, args: list of string)
{
@@ -78,6 +81,7 @@ init(nil: ref Draw->Context, args: list of string)
builtin("maketemp", domaketemp);
builtin("sinclude", dosinclude);
builtin("substr", dosubstr);
+ builtin("syscmd", dosyscmd);
builtin("translit", dotranslit);
builtin("undefine", doundefine);
builtin("undivert", doundivert);
@@ -670,6 +674,23 @@ domaketemp(args: array of string)
pushs(mktemp(args[1]));
}
+dosyscmd(args: array of string)
+{
+ if(len args > 1){
+ {
+ if(sh == nil){
+ sh = load Sh Sh->PATH;
+ if(sh == nil)
+ raise sys->sprint("load: can't load %s: %r", Sh->PATH);
+ }
+ sh->system(nil, args[1]);
+ }exception e{
+ "load:*" =>
+ error(e);
+ }
+ }
+}
+
sysname: string;
mktemp(s: string): string
@@ -685,7 +706,9 @@ mktemp(s: string): string
break;
}
# add system name, process ID and 'a'
- s += sys->sprint(".%s.%.10uda", sysname, sys->pctl(0, nil));
+ if(s != nil)
+ s += ".";
+ s += sys->sprint("%s.%.10uda", sysname, sys->pctl(0, nil));
while(sys->stat(s).t0 >= 0){
if(s[len s-1] == 'z')
error("out of temp files: "+s);
diff --git a/dis/m4.dis b/dis/m4.dis
index f5117e49..0d9e9606 100644
--- a/dis/m4.dis
+++ b/dis/m4.dis
Binary files differ
diff --git a/man/1/m4 b/man/1/m4
index ebfa9557..fcfb3e2d 100644
--- a/man/1/m4
+++ b/man/1/m4
@@ -199,10 +199,15 @@ number selecting the first character;
the third argument indicates the length of the substring.
A missing third argument is taken to be large enough to extend to
the end of the first string.
-\" .TP
-\" syscmd
-\" executes the shell command given in the first argument.
-\" No value is returned.
+.TP
+syscmd
+Runs the first argument as an
+.IR sh (1)
+command.
+No value is returned.
+Note that the output of a command can be redirected to a temporary file named by
+.BR maketemp ,
+included, and then removed.
.TP
translit
Transliterates the characters in its first argument