- int i, vecp = 0, inverted = 0, list = 0;
- int noalias = 0, normalize = AD_NHST;
- char *cp, **ap, **argp, buf[BUFSIZ];
- char *vec[NVEC], **arguments;
- struct aka *ak;
-
-#ifdef LOCALE
- setlocale(LC_ALL, "");
-#endif
- invo_name = r1bindex (argv[0], '/');
-
- /* read user profile/context */
- context_read();
-
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
- argp = arguments;
-
- while ((cp = *argp++)) {
- if (*cp == '-') {
- switch (smatch (++cp, switches)) {
- case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
- case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
-
- case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] aliases ...",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
- case VERSIONSW:
- print_version (invo_name);
- done (1);
-
- case ALIASW:
- 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++;
- continue;
-
- case LISTSW:
- list++;
- continue;
- case NLISTSW:
- list = 0;
- continue;
-
- case NORMSW:
- normalize = AD_HOST;
- continue;
- case NNORMSW:
- normalize = AD_NHST;
- continue;
-
- case USERSW:
- inverted++;
- continue;
- case NUSERSW:
- inverted = 0;
- continue;
- }
+ int i, vecp = 0, inverted = 0, list = 0;
+ int deffiles = 1, normalize = AD_NHST;
+ char *cp, **ap, **argp, buf[BUFSIZ];
+ char *vec[NVEC], **arguments;
+ struct aka *ak;
+
+ setlocale(LC_ALL, "");
+ invo_name = mhbasename(argv[0]);
+
+ /* read user profile/context */
+ context_read();
+
+ arguments = getarguments(invo_name, argc, argv, 1);
+ argp = arguments;
+
+ while ((cp = *argp++)) {
+ if (*cp == '-') {
+ switch (smatch(++cp, switches)) {
+ case AMBIGSW:
+ ambigsw(cp, switches);
+ exit(EX_USAGE);
+ case UNKWNSW:
+ adios(EX_USAGE, NULL, "-%s unknown", cp);
+
+ case HELPSW:
+ snprintf(buf, sizeof(buf), "%s [switches] aliases ...",
+ invo_name);
+ print_help(buf, switches, 1);
+ exit(argc == 2 ? EX_OK : EX_USAGE);
+ case VERSIONSW:
+ print_version(invo_name);
+ exit(argc == 2 ? EX_OK : EX_USAGE);
+
+ case FILESW:
+ if (!(cp = *argp++) || *cp == '-') {
+ adios(EX_USAGE, NULL, "missing argument to %s", argp[-2]);
+ }
+ if ((i = alias(cp)) != AK_OK)
+ adios(EX_USAGE, NULL, "aliasing error in %s: %s", cp, akerror(i));
+ deffiles = 0;
+ continue;
+
+ case LISTSW:
+ list++;
+ continue;
+ case NLISTSW:
+ list = 0;
+ continue;
+
+ case NORMSW:
+ normalize = AD_HOST;
+ continue;
+ case NNORMSW:
+ normalize = AD_NHST;
+ continue;
+
+ case USERSW:
+ inverted++;
+ continue;
+ case NUSERSW:
+ inverted = 0;
+ continue;
+ }
+ }
+ vec[vecp++] = cp;