mseq: allow message syntax in -c

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

@ -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.)

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

Loading…
Cancel
Save