X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fali.c;h=4d7617bff7802022721c0569e5ded3118b6854b9;hp=3d450d7244f5d603ebf42df1bd6d05b2a9d9aa53;hb=fede6e42d81ce34fd5c1bbe7fb2757b281c2573a;hpb=9f9bfa91d88b3ca4cd9206c1f2b17c6d13ebcaba diff --git a/uip/ali.c b/uip/ali.c index 3d450d7..4d7617b 100644 --- a/uip/ali.c +++ b/uip/ali.c @@ -9,7 +9,6 @@ #include #include #include -#include #include /* @@ -18,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 - { "nolist", 0 }, -#define NORMSW 4 +#define NLISTSW 2 + { "nolist", 2 }, +#define NORMSW 3 { "normalize", 0 }, -#define NNORMSW 5 - { "nonormalize", 0 }, -#define USERSW 6 +#define NNORMSW 4 + { "nonormalize", 2 }, +#define USERSW 5 { "user", 0 }, -#define NUSERSW 7 - { "nouser", 0 }, -#define VERSIONSW 8 - { "version", 0 }, -#define HELPSW 9 +#define NUSERSW 6 + { "nouser", 2 }, +#define VERSIONSW 7 + { "Version", 0 }, +#define HELPSW 8 { "help", 0 }, { NULL, 0 } }; @@ -56,20 +53,17 @@ 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; -#ifdef LOCALE setlocale(LC_ALL, ""); -#endif invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); - mts_init(invo_name); arguments = getarguments(invo_name, argc, argv, 1); argp = arguments; @@ -78,7 +72,8 @@ main(int argc, char **argv) switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + /* sysexits.h EX_USAGE */ + exit(1); case UNKWNSW: adios(NULL, "-%s unknown", cp); @@ -86,19 +81,17 @@ main(int argc, char **argv) snprintf(buf, sizeof(buf), "%s [switches] aliases ...", invo_name); print_help(buf, switches, 1); - done(1); + exit(0); case VERSIONSW: print_version(invo_name); - done(1); + exit(0); - 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: @@ -126,16 +119,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(*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); } } @@ -150,7 +146,7 @@ main(int argc, char **argv) for (i = 0; i < vecp; i++) print_usr(vec[i], list, normalize); - done(0); + exit(0); } if (vecp) { @@ -166,8 +162,7 @@ main(int argc, char **argv) } } - done(0); - return 1; + return 0; } static void