Use PROGNAME for mv(1) as well

This commit is contained in:
Pierre Pronchery 2018-01-30 00:48:16 +01:00
parent 0cff904d8b
commit 2eea5cdf5a

View File

@ -27,6 +27,11 @@
#include <limits.h> #include <limits.h>
#include <errno.h> #include <errno.h>
/* constants */
#ifndef PROGNAME
# define PROGNAME "mv"
#endif
/* types */ /* types */
typedef int Prefs; typedef int Prefs;
@ -65,7 +70,7 @@ static int _mv(Prefs * prefs, int filec, char * filev[])
static int _mv_error(char const * message, int ret) static int _mv_error(char const * message, int ret)
{ {
fputs("mv: ", stderr); fputs(PROGNAME ": ", stderr);
perror(message); perror(message);
return ret; return ret;
} }
@ -75,7 +80,7 @@ static int _mv_confirm(char const * dst)
int c; int c;
int tmp; int tmp;
fprintf(stderr, "%s%s%s", "mv: ", dst, ": Overwrite? "); fprintf(stderr, "%s%s%s", PROGNAME ": ", dst, ": Overwrite? ");
if((c = fgetc(stdin)) == EOF) if((c = fgetc(stdin)) == EOF)
return 0; return 0;
while(c != '\n' && (tmp = fgetc(stdin)) != EOF && tmp != '\n'); while(c != '\n' && (tmp = fgetc(stdin)) != EOF && tmp != '\n');
@ -305,8 +310,8 @@ static int _mv_multiple(Prefs * prefs, int filec, char * const filev[])
/* usage */ /* usage */
static int _usage(void) static int _usage(void)
{ {
fputs("Usage: mv [-fi] source_file target_file\n\ fputs("Usage: " PROGNAME " [-fi] source_file target_file\n\
mv [-fi] source_file... target_file\n\ " PROGNAME " [-fi] source_file... target_file\n\
-f Do not prompt for confirmation if the destination path exists\n\ -f Do not prompt for confirmation if the destination path exists\n\
-i Prompt for confirmation if the destination path exists\n", stderr); -i Prompt for confirmation if the destination path exists\n", stderr);
return 1; return 1;