2011-05-23 02:36:34 +01:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
2011-05-24 12:56:38 +01:00
|
|
|
#include <libgen.h>
|
2011-05-23 02:36:34 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2013-03-05 21:35:55 +01:00
|
|
|
|
2011-05-23 02:36:34 +01:00
|
|
|
#include "util.h"
|
|
|
|
|
2012-05-15 13:32:56 +01:00
|
|
|
static void usage(void);
|
2012-04-23 15:50:47 +02:00
|
|
|
|
2013-03-05 21:35:55 +01:00
|
|
|
void
|
|
|
|
usage(void)
|
|
|
|
{
|
|
|
|
eprintf("usage: %s name [suffix]\n", argv0);
|
|
|
|
}
|
|
|
|
|
2011-05-23 02:36:34 +01:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2014-11-13 14:24:26 +00:00
|
|
|
char *s, *p;
|
2012-04-23 15:50:47 +02:00
|
|
|
|
|
|
|
ARGBEGIN {
|
|
|
|
default:
|
2012-05-15 13:32:56 +01:00
|
|
|
usage();
|
2012-04-23 15:50:47 +02:00
|
|
|
} ARGEND;
|
|
|
|
|
2014-11-13 18:29:30 +01:00
|
|
|
if (argc < 1)
|
2012-05-15 13:32:56 +01:00
|
|
|
usage();
|
2012-04-23 15:50:47 +02:00
|
|
|
|
2012-04-23 16:32:41 +02:00
|
|
|
s = basename(argv[0]);
|
2014-11-13 18:29:30 +01:00
|
|
|
if (argc == 2) {
|
2014-11-13 14:24:26 +00:00
|
|
|
p = strstr(s, argv[1]);
|
|
|
|
if (p && p[strlen(p)] == '\0')
|
|
|
|
*p = '\0';
|
2011-05-23 02:36:34 +01:00
|
|
|
}
|
2012-04-23 16:32:41 +02:00
|
|
|
puts(s);
|
2014-10-02 23:46:04 +01:00
|
|
|
return 0;
|
2011-05-23 02:36:34 +01:00
|
|
|
}
|