move debugging to safe place (before vfork)
[oweals/busybox.git] / coreutils / length.c
index c7df216112216bfad014246c66d51ece8b089f64..bce43ab3ff7fdbc90684833eb4c53024d8816cbc 100644 (file)
@@ -1,18 +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"
-#ifndef BB_FEATURE_TRIVIAL_HELP
-                               "\nPrints out the length of the specified STRING.\n"
-#endif
-                               );
+       if ((argc != 2) ||  (**(++argv) == '-')) {
+           bb_show_usage();
        }
-       printf("%lu\n", (long)strlen(argv[1]));
-       return (TRUE);
+
+       bb_printf("%lu\n", (unsigned long)strlen(*argv));
+
+       bb_fflush_stdout_and_exit(EXIT_SUCCESS);
 }