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