move debugging to safe place (before vfork)
[oweals/busybox.git] / coreutils / length.c
index 00e5a171bf5208c8a6d2c559d3c5fe71ef65f16c..bce43ab3ff7fdbc90684833eb4c53024d8816cbc 100644 (file)
@@ -1,14 +1,19 @@
 /* vi: set sw=4 ts=4: */
-#include "internal.h"
+
+/* BB_AUDIT SUSv3 N/A -- Apparently a busybox (obsolete?) extension. */
+
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include "busybox.h"
 
 extern int length_main(int argc, char **argv)
 {
-       if (argc != 2 || **(argv + 1) == '-') {
-               usage("length string\n");
+       if ((argc != 2) ||  (**(++argv) == '-')) {
+           bb_show_usage();
        }
-       printf("%d\n", strlen(argv[1]));
-       return (TRUE);
+
+       bb_printf("%lu\n", (unsigned long)strlen(*argv));
+
+       bb_fflush_stdout_and_exit(EXIT_SUCCESS);
 }