*
*/
-#include "internal.h"
+#include "busybox.h"
#define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#define bb_need_omitting_directory
#define is_cp 0
#define is_mv 1
static int dz_i; /* index into cp_mv_usage */
+
static const char *cp_mv_usage[] = /* .rodata */
{
- "cp [OPTION]... SOURCE DEST\n"
- " or: cp [OPTION]... SOURCE... DIRECTORY\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nCopies SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
- "\n"
- "\t-a\tSame as -dpR\n"
- "\t-d\tPreserves links\n"
- "\t-p\tPreserves file attributes if possible\n"
- "\t-f\tforce (implied; ignored) - always set\n"
- "\t-R\tCopies directories recursively\n"
-#endif
- ,
- "mv SOURCE DEST\n"
- " or: mv SOURCE... DIRECTORY\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nRename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"
-#endif
+ cp_usage,
+ mv_usage
};
static int recursiveFlag;
extern int cp_mv_main(int argc, char **argv)
{
volatile int i;
- char c;
+ int c;
if (*applet_name == 'c' && *(applet_name + 1) == 'p')
dz_i = is_cp;
usage(cp_mv_usage[dz_i]);
}
} else { /* (dz_i == is_mv) */
+ /* Initialize optind to 1, since in libc5 optind
+ * is not initialized until getopt() is called
+ * (or until sneaky programmers force it...). */
+ optind = 1;
recursiveFlag = preserveFlag = TRUE;
followLinks = FALSE;
}
goto exit_false;
destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf);
- if ((argc > 3) && destDirFlag == FALSE) {
+ if (argc - optind > 2 && destDirFlag == FALSE) {
errorMsg(not_a_directory, baseDestName);
goto exit_false;
}