From b8631d13ffcf962ad47478cfa0e0552919ad8f40 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Tue, 9 Aug 2016 19:10:12 +0200 Subject: mseq: allow message syntax in -c --- man/mseq.1 | 8 ++++---- mseq.c | 16 ++++++++++++++-- 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; @@ -239,6 +240,14 @@ stdinmode() return 0; } +void +overridecur(char *file) +{ + while (*file == ' ') + file++; + setenv("MAILDOT", file, 1); +} + void setcur(char *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; -- cgit 1.4.1