mseq: allow message syntax in -c

pull/2/head
Christian Neukirchen 8 years ago
parent f34a284b42
commit b8631d13ff

@ -7,7 +7,7 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl fr .Op Fl fr
.Op Fl c Ar file .Op Fl c Ar msg
.Ar msgs\ ... .Ar msgs\ ...
.Nm .Nm
.Fl S .Fl S
@ -46,9 +46,9 @@ If standard output is not a terminal, the new sequence is also printed.
.Pp .Pp
The options are as follows: The options are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl c Ar file .It Fl c Ar msg
Behave as if Behave as if
.Ar file .Ar msg
was the current message. was the current message.
.It Fl f .It Fl f
Fix non-existing filenames by searching for a message with the same Fix non-existing filenames by searching for a message with the same
@ -73,7 +73,7 @@ Symbolic link referring to the current message.
(Default: (Default:
.Pa ~/.mblaze/cur ) .Pa ~/.mblaze/cur )
.It Ev MAILDOT .It Ev MAILDOT
When set, overrides the current message. When set to a file name, overrides the current message.
(Prefer using (Prefer using
.Fl c .Fl c
instead.) instead.)

@ -12,6 +12,7 @@
static int fflag; static int fflag;
static int rflag; static int rflag;
static int Aflag; static int Aflag;
static char *cflag;
static char *Cflag; static char *Cflag;
static int Sflag; static int Sflag;
@ -239,6 +240,14 @@ stdinmode()
return 0; return 0;
} }
void
overridecur(char *file)
{
while (*file == ' ')
file++;
setenv("MAILDOT", file, 1);
}
void void
setcur(char *file) setcur(char *file)
{ {
@ -253,7 +262,7 @@ main(int argc, char *argv[])
int c; int c;
while ((c = getopt(argc, argv, "c:frAC:S")) != -1) while ((c = getopt(argc, argv, "c:frAC:S")) != -1)
switch(c) { switch(c) {
case 'c': setenv("MAILDOT", optarg, 1); break; case 'c': cflag = optarg; break;
case 'f': fflag = 1; break; case 'f': fflag = 1; break;
case 'r': rflag = 1; break; case 'r': rflag = 1; break;
case 'A': Sflag = Aflag = 1; break; case 'A': Sflag = Aflag = 1; break;
@ -262,7 +271,7 @@ main(int argc, char *argv[])
default: default:
usage: usage:
fprintf(stderr, fprintf(stderr,
"Usage: mseq [-fr] [-c file] [msgs...]\n" "Usage: mseq [-fr] [-c msg] [msgs...]\n"
" mseq -S [-fr] < sequence\n" " mseq -S [-fr] < sequence\n"
" mseq -A [-fr] < sequence\n" " mseq -A [-fr] < sequence\n"
" mseq -C msg\n" " mseq -C msg\n"
@ -270,6 +279,9 @@ main(int argc, char *argv[])
exit(1); exit(1);
} }
if (cflag)
blaze822_loop1(cflag, overridecur);
if (Cflag) { if (Cflag) {
blaze822_loop1(Cflag, setcur); blaze822_loop1(Cflag, setcur);
return 0; return 0;

Loading…
Cancel
Save