#include <h/tws.h>
#include <unistd.h>
#include <locale.h>
+#include <sysexits.h>
static struct swit switches[] = {
#define VERSIONSW 0
{ NULL, 0 }
};
+char *version=VERSION;
int
main(int argc, char **argv)
switch (smatch(++cp, switches)) {
case AMBIGSW:
ambigsw(cp, switches);
- exit(1);
+ exit(EX_USAGE);
case UNKWNSW:
- adios(NULL, "-%s unknown", cp);
+ adios(EX_USAGE, NULL, "-%s unknown", cp);
case HELPSW:
snprintf(buf, sizeof(buf),
"%s [switches] file",
invo_name);
print_help(buf, switches, 1);
- exit(0);
+ exit(argc == 2 ? EX_OK : EX_USAGE);
case VERSIONSW:
print_version(invo_name);
- exit(0);
+ exit(argc == 2 ? EX_OK : EX_USAGE);
}
}
if (file)
- adios(NULL, "only one file at a time!");
+ adios(EX_USAGE, NULL, "only one file at a time!");
else
file = cp;
}