Use PROGNAME in more programs
This commit is contained in:
parent
3634f2592c
commit
f7a6ab0ff9
|
@ -22,6 +22,7 @@
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
#ifndef PROGNAME
|
#ifndef PROGNAME
|
||||||
# define PROGNAME "grep"
|
# define PROGNAME "grep"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "head"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* head */
|
/* head */
|
||||||
static int _head_error(char const * message, int ret);
|
static int _head_error(char const * message, int ret);
|
||||||
|
@ -39,7 +44,7 @@ static int _head(int flgn, int filec, char * filev[])
|
||||||
|
|
||||||
static int _head_error(char const * message, int ret)
|
static int _head_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("head: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +74,7 @@ static int _head_do(int flgn, char const * filename)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: head [-n number][file...]\n\
|
fputs("Usage: " PROGNAME " [-n number][file...]\n\
|
||||||
-n Print first number lines on standard output\n", stderr);
|
-n Print first number lines on standard output\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
13
src/kill.c
13
src/kill.c
|
@ -24,6 +24,11 @@
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "kill"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* kill */
|
/* kill */
|
||||||
/* private */
|
/* private */
|
||||||
|
@ -120,7 +125,7 @@ static int _kill(int sig, int argc, char * argv[])
|
||||||
pid = strtol(argv[i], &p, 10);
|
pid = strtol(argv[i], &p, 10);
|
||||||
if(argv[i][0] == '\0' || *p != '\0')
|
if(argv[i][0] == '\0' || *p != '\0')
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s%s%s", "kill: ", argv[i],
|
fprintf(stderr, "%s%s%s", PROGNAME ": ", argv[i],
|
||||||
": Invalid process number\n");
|
": Invalid process number\n");
|
||||||
ret |= 1;
|
ret |= 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -146,7 +151,7 @@ static int _kill_list(int argc, char * argv[])
|
||||||
/* error */
|
/* error */
|
||||||
static int _kill_error(char const * message, int ret)
|
static int _kill_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: %s\n", "kill", message);
|
fprintf(stderr, "%s: %s\n", PROGNAME, message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,8 +159,8 @@ static int _kill_error(char const * message, int ret)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: kill -s signal_name pid...\n\
|
fputs("Usage: " PROGNAME " -s signal_name pid...\n\
|
||||||
kill -l [exit_status]\n\
|
" PROGNAME " -l [exit_status]\n\
|
||||||
-l Write all signal values supported\n\
|
-l Write all signal values supported\n\
|
||||||
-s Specify the signal to send\n", stderr);
|
-s Specify the signal to send\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "link"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* link */
|
/* link */
|
||||||
static int _link_error(char const * message, int ret);
|
static int _link_error(char const * message, int ret);
|
||||||
|
@ -31,7 +36,7 @@ static int _link(char * file1, char * file2)
|
||||||
|
|
||||||
static int _link_error(char const * message, int ret)
|
static int _link_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("link: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +45,7 @@ static int _link_error(char const * message, int ret)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: link file1 file2\n", stderr);
|
fputs("Usage: " PROGNAME " file1 file2\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
src/ln.c
11
src/ln.c
|
@ -25,6 +25,11 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "ln"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* types */
|
/* types */
|
||||||
/* force link */
|
/* force link */
|
||||||
|
@ -62,7 +67,7 @@ static int _ln(LinkForce lf, LinkType lt, int argc, char * argv[])
|
||||||
|
|
||||||
static int _ln_error(char const * message, int ret)
|
static int _ln_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("ln: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -113,8 +118,8 @@ static int _ln_multiple(LinkForce lf, LinkType lt, int argc, char * argv[])
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: ln [-fs] source_file target_file\n\
|
fputs("Usage: " PROGNAME " [-fs] source_file target_file\n\
|
||||||
ln [-fs] source_file ... target_dir\n\
|
" PROGNAME " [-fs] source_file ... target_dir\n\
|
||||||
-f Force existing destination pathnames to be removed\n\
|
-f Force existing destination pathnames to be removed\n\
|
||||||
-s Create symbolic links instead of hard links\n", stderr);
|
-s Create symbolic links instead of hard links\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -19,6 +19,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "locale"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* prefs */
|
/* prefs */
|
||||||
typedef int Prefs;
|
typedef int Prefs;
|
||||||
|
@ -92,8 +97,8 @@ static int _locale_do(Prefs * p, char const * locale)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: locale [-a | -m]\n\
|
fputs("Usage: " PROGNAME " [-a | -m]\n\
|
||||||
locale [-ck]\n", stderr);
|
" PROGNAME " [-ck]\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "logname"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* logname */
|
/* logname */
|
||||||
static int _logname_error(char const * message, int ret);
|
static int _logname_error(char const * message, int ret);
|
||||||
|
@ -34,7 +39,7 @@ static int _logname(void)
|
||||||
|
|
||||||
static int _logname_error(char const * message, int ret)
|
static int _logname_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("logname: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +48,7 @@ static int _logname_error(char const * message, int ret)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: logname\n", stderr);
|
fputs("Usage: " PROGNAME "\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
#define COMMON_MODE
|
#define COMMON_MODE
|
||||||
#include "common.c"
|
#include "common.c"
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "mkdir"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* mkdir */
|
/* mkdir */
|
||||||
static int _mkdir_error(char const * message, int ret);
|
static int _mkdir_error(char const * message, int ret);
|
||||||
|
@ -47,7 +52,7 @@ static int _mkdir(int flagp, mode_t mode, int filec, char * filev[])
|
||||||
|
|
||||||
static int _mkdir_error(char const * message, int ret)
|
static int _mkdir_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("mkdir: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +86,7 @@ static int _mkdir_p(mode_t mode, char * pathname)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: mkdir [-p][-m mode] dir...\n\
|
fputs("Usage: " PROGNAME " [-p][-m mode] dir...\n\
|
||||||
-p Create any missing intermediate pathname components\n\
|
-p Create any missing intermediate pathname components\n\
|
||||||
-m File permission bits of the newly-created directory\n", stderr);
|
-m File permission bits of the newly-created directory\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
#define COMMON_MODE
|
#define COMMON_MODE
|
||||||
#include "common.c"
|
#include "common.c"
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "mkfifo"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* mkfifo */
|
/* mkfifo */
|
||||||
static int _mkfifo_error(char const * message, int ret);
|
static int _mkfifo_error(char const * message, int ret);
|
||||||
|
@ -41,7 +46,7 @@ static int _mkfifo(mode_t mode, int filec, char * filev[])
|
||||||
|
|
||||||
static int _mkfifo_error(char const * message, int ret)
|
static int _mkfifo_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("mkfifo: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +55,7 @@ static int _mkfifo_error(char const * message, int ret)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: mkfifo [-m mode] file...\n\
|
fputs("Usage: " PROGNAME " [-m mode] file...\n\
|
||||||
-m Create fifo with the specified mode value\n", stderr);
|
-m Create fifo with the specified mode value\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "more"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* more */
|
/* more */
|
||||||
/* private */
|
/* private */
|
||||||
|
@ -86,7 +91,7 @@ static int _more_do(Prefs * prefs, char const * filename)
|
||||||
/* more_error */
|
/* more_error */
|
||||||
static int _more_error(char const * message, int ret)
|
static int _more_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("more: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +100,7 @@ static int _more_error(char const * message, int ret)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: more [file...]\n", stderr);
|
fputs("Usage: " PROGNAME " [file...]\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "nice"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* nice */
|
/* nice */
|
||||||
static int _nice_error(char const * message, int ret);
|
static int _nice_error(char const * message, int ret);
|
||||||
|
@ -35,7 +40,7 @@ static int _nice(int nice, char * argv[])
|
||||||
|
|
||||||
static int _nice_error(char const * message, int ret)
|
static int _nice_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("nice: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +49,7 @@ static int _nice_error(char const * message, int ret)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: nice [-n increment] utility [argument...]\n\
|
fputs("Usage: " PROGNAME " [-n increment] utility [argument...]\n\
|
||||||
-n Priority to set\n", stderr);
|
-n Priority to set\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
9
src/pr.c
9
src/pr.c
|
@ -22,6 +22,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "pr"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* pr */
|
/* pr */
|
||||||
/* types */
|
/* types */
|
||||||
|
@ -71,7 +76,7 @@ static int _pr(Prefs * prefs, int filec, char * filev[])
|
||||||
|
|
||||||
static int _pr_error(char const * message, int ret)
|
static int _pr_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("pr: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +201,7 @@ static void _do_footer(Prefs * prefs)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: pr [+page][-column][-adFmrt][-e [char][ gap]]"
|
fputs("Usage: " PROGNAME " [+page][-column][-adFmrt][-e [char][ gap]]"
|
||||||
"[-h header][-i[char][gap]]\n"
|
"[-h header][-i[char][gap]]\n"
|
||||||
"[-l lines][-n [char][width]][-o offset][-s[char]]"
|
"[-l lines][-n [char][width]][-o offset][-s[char]]"
|
||||||
"[-w width] file...\n",
|
"[-w width] file...\n",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user