Hi,
Jan Stary wrote on Tue, Oct 11, 2016 at 07:53:23AM +0200:
> cp(1) and rm(1) call setlocale(LC_ALL, "") but mv(1) does not.
> Why do they do that, and why mv doesn't?
That is useless and wasteful.
I think it comes from a time when people still thought that doing
more and more and more might bring you closer to perfection.
Here is a simple diff to remove that junk
and to properly return from main() while here.
OK?
Ingo
P.S.
By the way, i consider any occurrence of LC_ALL in /usr/src/ outside
lib/libc/ and gnu/ a (very minor) bug. We never want LC_ALL for
anything. If locales are needed at all, we only want LC_CTYPE.
Index: cp/cp.c
===================================================================
RCS file: /cvs/src/bin/cp/cp.c,v
retrieving revision 1.43
diff -u -p -r1.43 cp.c
--- cp/cp.c 7 Mar 2016 18:56:33 -0000 1.43
+++ cp/cp.c 11 Oct 2016 08:22:31 -0000
@@ -58,12 +58,11 @@
#include <errno.h>
#include <fcntl.h>
#include <fts.h>
-#include <locale.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <limits.h>
#include "extern.h"
@@ -88,8 +87,6 @@ main(int argc, char *argv[])
int Hflag, Lflag, Pflag, ch, fts_options, r;
char *target;
- (void)setlocale(LC_ALL, "");
-
Hflag = Lflag = Pflag = Rflag = 0;
while ((ch = getopt(argc, argv, "HLPRfipr")) != -1)
switch (ch) {
@@ -232,7 +229,7 @@ main(int argc, char *argv[])
type = FILE_TO_DIR;
}
- exit(copy(argv, type, fts_options));
+ return copy(argv, type, fts_options);
}
char *
Index: rm/rm.c
===================================================================
RCS file: /cvs/src/bin/rm/rm.c,v
retrieving revision 1.39
diff -u -p -r1.39 rm.c
--- rm/rm.c 28 Jun 2016 18:00:59 -0000 1.39
+++ rm/rm.c 11 Oct 2016 08:22:33 -0000
@@ -34,7 +34,6 @@
#include <sys/stat.h>
#include <sys/mount.h>
-#include <locale.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
@@ -73,8 +72,6 @@ main(int argc, char *argv[])
{
int ch, rflag;
- setlocale(LC_ALL, "");
-
Pflag = rflag = 0;
while ((ch = getopt(argc, argv, "dfiPRr")) != -1)
switch(ch) {
@@ -124,7 +121,7 @@ main(int argc, char *argv[])
rm_file(argv);
}
- exit(eval);
+ return eval;
}
void