Use PROGNAME in more programs
This commit is contained in:
parent
87efa6602b
commit
b7682f3b9f
|
@ -19,6 +19,11 @@
|
|||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "dirname"
|
||||
#endif
|
||||
|
||||
|
||||
/* dirname */
|
||||
static int _dirname(char * arg)
|
||||
|
@ -31,7 +36,7 @@ static int _dirname(char * arg)
|
|||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: dirname string\n", stderr);
|
||||
fputs("Usage: " PROGNAME " string\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
9
src/du.c
9
src/du.c
|
@ -23,6 +23,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "du"
|
||||
#endif
|
||||
|
||||
|
||||
/* Prefs */
|
||||
typedef int Prefs;
|
||||
|
@ -51,7 +56,7 @@ static int _du(Prefs * prefs, int argc, char * argv[])
|
|||
|
||||
static int _du_error(char const * error)
|
||||
{
|
||||
fputs("du: ", stderr);
|
||||
fputs(PROGNAME ": ", stderr);
|
||||
perror(error);
|
||||
return 1;
|
||||
}
|
||||
|
@ -183,7 +188,7 @@ static void _du_print(Prefs * prefs, off_t size, char const * filename)
|
|||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: du [-a | -s][-kx][-H | -L][file...]\n\
|
||||
fputs("Usage: " PROGNAME " [-a | -s][-kx][-H | -L][file...]\n\
|
||||
-a Report the size of every file encountered\n\
|
||||
-s Report only the total sum for each of the specified files\n\
|
||||
-k Write the file sizes in units of 1024 bytes rather than 512\n\
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "echo"
|
||||
#endif
|
||||
|
||||
|
||||
/* echo */
|
||||
static int _echo(int argc, char * argv[])
|
||||
|
@ -38,7 +43,7 @@ static int _echo(int argc, char * argv[])
|
|||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: echo [string...]\n", stderr);
|
||||
fputs("Usage: " PROGNAME " [string...]\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,16 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "false"
|
||||
#endif
|
||||
|
||||
|
||||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: false\n", stderr);
|
||||
fputs("Usage: " PROGNAME "\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "file"
|
||||
#endif
|
||||
|
||||
|
||||
/* prefs */
|
||||
typedef int Prefs;
|
||||
|
@ -83,8 +88,8 @@ static int _file_do(Prefs * p, char const * filename)
|
|||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: file [-dh][-M file][-m file] file ...\n\
|
||||
file -i [-h] file ...\n", stderr);
|
||||
fputs("Usage: " PROGNAME " [-dh][-M file][-m file] file ...\n\
|
||||
" PROGNAME " -i [-h] file ...\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
11
src/find.c
11
src/find.c
|
@ -29,6 +29,11 @@
|
|||
#include <grp.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "find"
|
||||
#endif
|
||||
|
||||
|
||||
/* types */
|
||||
typedef int Prefs;
|
||||
|
@ -85,14 +90,14 @@ static int _find(Prefs * prefs, int argc, char * argv[])
|
|||
|
||||
static int _find_error(char const * message, int ret)
|
||||
{
|
||||
fputs("find: ", stderr);
|
||||
fputs(PROGNAME ": ", stderr);
|
||||
perror(message);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int _find_error_user(char const * message, char const * error, int ret)
|
||||
{
|
||||
fprintf(stderr, "%s%s: %s\n", "find: ", message, error);
|
||||
fprintf(stderr, "%s%s: %s\n", PROGNAME ": ", message, error);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -308,7 +313,7 @@ static int _do_dir(Prefs * prefs, char const * pathname, int cmdc,
|
|||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: find [-H|-L] path... [expression...]\n"
|
||||
fputs("Usage: " PROGNAME " [-H|-L] path... [expression...]\n"
|
||||
" -H De-reference links unless dangling or in the command line\n"
|
||||
" -L De-reference links always\n", stderr);
|
||||
return 1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user