As promised, here is the small patch for the standard empire command
line client to make it easier to run everything through your pager
(or other things) again and again.
The patch is quite trivial. My changes to the pipe documentation
under "Syntax" are actually longer than the change to the code.
This is a strict client-side feature and the improvement will work
against unpatched servers just as nicely. However, when you run
"info Syntax" with them, you'll get their standard, un-improved
documentation. Simply reading the info patch below once will get
you educated well enough, I think.
Martin
Index: src/client/servcmd.c
===================================================================
RCS file: /cvsroot/empserver/empserver/src/client/servcmd.c,v
retrieving revision 1.50
diff -u -r1.50 servcmd.c
--- src/client/servcmd.c 13 Dec 2007 21:36:25 -0000 1.50
+++ src/client/servcmd.c 16 Oct 2009 23:25:43 -0000
@@ -45,6 +45,7 @@
#include "misc.h"
#include "proto.h"
#include "secure.h"
+#include "linebuf.h"
#ifdef _WIN32
#define open(filename, flags, ...) \
@@ -230,6 +231,8 @@
static void
dopipe(char *p)
{
+ static char last_pipe_cmd[LBUF_LEN_MAX] = "more";
+
if (!redir_authorized(p, "pipe to shell command", !redir_fp))
return;
if (*p++ != '|') {
@@ -238,10 +241,10 @@
}
for (; *p && isspace(*p); p++) ;
- if (*p == 0) {
- fprintf(stderr, "Redirection lacks a command\n");
- return;
- }
+ if (*p)
+ strncpy (last_pipe_cmd, p, sizeof(last_pipe_cmd)-1);
+ else
+ p = last_pipe_cmd;
redir_is_pipe = 1;
if ((redir_fp = popen(p, "w")) == NULL) {
Index: info/Syntax.t
===================================================================
RCS file: /cvsroot/empserver/empserver/info/Syntax.t,v
retrieving revision 1.1
diff -u -r1.1 Syntax.t
--- info/Syntax.t 22 Dec 2005 10:09:17 -0000 1.1
+++ info/Syntax.t 16 Oct 2009 23:25:43 -0000
@@ -136,11 +136,41 @@
replacing the file it if it already exists.
.s1
.ne 2
-.EX VERB ARG ... | PROGRAM [ARGS...]
+.EX VERB ARG ... | [ PROGRAM [ARGS...] ]
which send the output of the command to the program \*QPROGRAM\*U
with optional arguments \*QARGS\*U.
This is most useful when \*QPROGRAM\*U is some type of
pager like \*(iFmore\*(pF(1) or \*(iFless\*(pF(1).
+In fact, Empire starts out with the \*(iFmore\*(pF(1)
+pager as your default pipe program.
+Caveat: you should be careful to specify all required
+arguments for your empire verb right away on the command
+line. For example, while
+.EX news | more
+will work fine, reading your telegrams with
+.EX read | more
+will appear to mysteriously hang without any output.
+What happens is this:
+telegrams and the final prompt "Into the shredder, boss?"
+all vanish into the pipe buffer.
+You have to answer the
+"interactive" argument prompt blindly with a "yes" or "no" before
+you can see the whole shebang.
+Better specify such arguments right away:
+.EX read y | more
+.s1
+If you do not specify any program (and just end your
+command with a | character), the same program as the
+last time will be used.
+This makes it much easier to use your pager again and again.
+Another example: the sequence
+.NF
+show s b | grep ^frg
+show s c |
+show s s |
+.FI
+will tell you everything about frigates and not bother you
+with other ship types.
.s1
The Empire shell also recognizes a few control characters:
.s1