mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit b8631d13ffcf962ad47478cfa0e0552919ad8f40
parent f34a284b42961eef3f121be84b728a6c1301ad9d
Author: Christian Neukirchen <chneukirchen@gmail.com>
Date:   Tue,  9 Aug 2016 19:10:12 +0200

mseq: allow message syntax in -c

Diffstat:
man/mseq.1 | 8++++----
mseq.c | 16++++++++++++++--
2 files changed, 18 insertions(+), 6 deletions(-)

diff --git 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 @@ -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;