aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-08-09 19:10:12 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-08-09 19:10:12 +0200
commitb8631d13ffcf962ad47478cfa0e0552919ad8f40 (patch)
tree6bf9b0a54ab1ef6317abd7796e509e9ac4c0a2d8
parentf34a284b42961eef3f121be84b728a6c1301ad9d (diff)
downloadmblaze-b8631d13ffcf962ad47478cfa0e0552919ad8f40.tar.gz
mseq: allow message syntax in -c
-rw-r--r--man/mseq.18
-rw-r--r--mseq.c16
2 files changed, 18 insertions, 6 deletions
diff --git a/man/mseq.1 b/man/mseq.1
index e514ece..50b1029 100644
--- a/man/mseq.1
+++ b/man/mseq.1
@@ -7,7 +7,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl fr
-.Op Fl c Ar file
+.Op Fl c Ar msg
.Ar msgs\ ...
.Nm
.Fl S
@@ -46,9 +46,9 @@ If standard output is not a terminal, the new sequence is also printed.
.Pp
The options are as follows:
.Bl -tag -width Ds
-.It Fl c Ar file
+.It Fl c Ar msg
Behave as if
-.Ar file
+.Ar msg
was the current message.
.It Fl f
Fix non-existing filenames by searching for a message with the same
@@ -73,7 +73,7 @@ Symbolic link referring to the current message.
(Default:
.Pa ~/.mblaze/cur )
.It Ev MAILDOT
-When set, overrides the current message.
+When set to a file name, overrides the current message.
(Prefer using
.Fl c
instead.)
diff --git a/mseq.c b/mseq.c
index d282811..5602c4e 100644
--- a/mseq.c
+++ b/mseq.c
@@ -12,6 +12,7 @@
static int fflag;
static int rflag;
static int Aflag;
+static char *cflag;
static char *Cflag;
static int Sflag;
@@ -240,6 +241,14 @@ stdinmode()
}
void
+overridecur(char *file)
+{
+ while (*file == ' ')
+ file++;
+ setenv("MAILDOT", file, 1);
+}
+
+void
setcur(char *file)
{
while (*file == ' ')
@@ -253,7 +262,7 @@ main(int argc, char *argv[])
int c;
while ((c = getopt(argc, argv, "c:frAC:S")) != -1)
switch(c) {
- case 'c': setenv("MAILDOT", optarg, 1); break;
+ case 'c': cflag = optarg; break;
case 'f': fflag = 1; break;
case 'r': rflag = 1; break;
case 'A': Sflag = Aflag = 1; break;
@@ -262,7 +271,7 @@ main(int argc, char *argv[])
default:
usage:
fprintf(stderr,
- "Usage: mseq [-fr] [-c file] [msgs...]\n"
+ "Usage: mseq [-fr] [-c msg] [msgs...]\n"
" mseq -S [-fr] < sequence\n"
" mseq -A [-fr] < sequence\n"
" mseq -C msg\n"
@@ -270,6 +279,9 @@ main(int argc, char *argv[])
exit(1);
}
+ if (cflag)
+ blaze822_loop1(cflag, overridecur);
+
if (Cflag) {
blaze822_loop1(Cflag, setcur);
return 0;