From 4d83cd450b889b65ffab1c352d6580bd5632aae1 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Wed, 27 Jun 2012 22:01:55 +0200 Subject: [PATCH] ali: Either read default alias files or the ones on command line. Renamed -alias to -file because the semantic changed and the new name appears to be better suited. --- man/ali.man1 | 24 ++++++++++++++++-------- man/mh-alias.man5 | 2 -- uip/ali.c | 53 ++++++++++++++++++++++++++--------------------------- 3 files changed, 42 insertions(+), 37 deletions(-) diff --git a/man/ali.man1 b/man/ali.man1 index 72898c0..b45fb92 100644 --- a/man/ali.man1 +++ b/man/ali.man1 @@ -8,8 +8,8 @@ ali \- list mail aliases .HP 5 .na .B ali -.RB [ \-alias -.IR aliasfile ] +.RB [ \-file +.IR aliasfile ]... .RB [ \-list " | " \-nolist ] .RB [ \-normalize " | " \-nonormalize ] .RB [ \-user " | " \-nouser ] @@ -50,12 +50,20 @@ switch is given, will try to track down the official hostname of the address. .PP -The files specified by the profile entry -.RI ` Aliasfile ' -and any additional alias files given by the -.B \-alias +If no +.B \-file .I aliasfile -switch will be read. Each +is given, then the default alias files, as specified by the profile entry +.RI ` Aliasfile ', +will be read. +If any alias files are given by +.B \-file +.I aliasfile +switches, these will be read instead of the default alias files. +Either the default alias files are read or the ones given at the +command line, never both. +.PP +Each .I alias is processed as described in .BR mh\-alias (5). @@ -75,7 +83,7 @@ is processed as described in .ta 2.4i .ta \w'ExtraBigProfileName 'u ^Path:~^To determine the user's mail storage -^Aliasfile:~^For a default alias file +^Aliasfile:~^For default alias files .fi .SH "SEE ALSO" diff --git a/man/mh-alias.man5 b/man/mh-alias.man5 index e1e14fc..90cb9ba 100644 --- a/man/mh-alias.man5 +++ b/man/mh-alias.man5 @@ -205,8 +205,6 @@ and add the line: .RS 5 .nf Aliasfile: aliases -.\" ali: \-alias aliases -.\" send: \-alias aliases .fi .RE .PP diff --git a/uip/ali.c b/uip/ali.c index b5bbfbe..2c80147 100644 --- a/uip/ali.c +++ b/uip/ali.c @@ -17,25 +17,23 @@ #define NVEC 50 static struct swit switches[] = { -#define ALIASW 0 - { "alias aliasfile", 0 }, -#define NALIASW 1 - { "noalias", -7 }, -#define LISTSW 2 +#define FILESW 0 + { "file aliasfile", 0 }, +#define LISTSW 1 { "list", 0 }, -#define NLISTSW 3 +#define NLISTSW 2 { "nolist", 2 }, -#define NORMSW 4 +#define NORMSW 3 { "normalize", 0 }, -#define NNORMSW 5 +#define NNORMSW 4 { "nonormalize", 2 }, -#define USERSW 6 +#define USERSW 5 { "user", 0 }, -#define NUSERSW 7 +#define NUSERSW 6 { "nouser", 2 }, -#define VERSIONSW 8 +#define VERSIONSW 7 { "Version", 0 }, -#define HELPSW 9 +#define HELPSW 8 { "help", 0 }, { NULL, 0 } }; @@ -55,7 +53,7 @@ int main(int argc, char **argv) { int i, vecp = 0, inverted = 0, list = 0; - int noalias = 0, normalize = AD_NHST; + int deffiles = 1, normalize = AD_NHST; char *cp, **ap, **argp, buf[BUFSIZ]; char *vec[NVEC], **arguments; struct aka *ak; @@ -87,14 +85,12 @@ main(int argc, char **argv) print_version(invo_name); done(1); - case ALIASW: + case FILESW: if (!(cp = *argp++) || *cp == '-') adios(NULL, "missing argument to %s", argp[-2]); if ((i = alias(cp)) != AK_OK) - adios(NULL, "aliasing error in %s - %s", cp, akerror(i)); - continue; - case NALIASW: - noalias++; + adios(NULL, "aliasing error in %s: %s", cp, akerror(i)); + deffiles = 0; continue; case LISTSW: @@ -122,16 +118,19 @@ main(int argc, char **argv) vec[vecp++] = cp; } - if (!noalias) { - /* allow Aliasfile: profile entry */ - if ((cp = context_find("Aliasfile"))) { - char *dp = NULL; + /* process default Aliasfile: profile entry */ + if (deffiles && (cp = context_find("Aliasfile"))) { + char *dp = NULL; - for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++) - if ((i = alias(etcpath(*ap))) != AK_OK) - adios(NULL, "aliasing error in %s - %s", *ap, akerror(i)); - if (dp) - free(dp); + for (ap = brkstring(dp=getcpy(cp), " ", "\n"); + ap && *ap; ap++) { + if ((i = alias(etcpath(*ap))) != AK_OK) { + adios(NULL, "aliasing error in %s: %s", + *ap, akerror(i)); + } + } + if (dp) { + free(dp); } } -- 1.7.10.4