From de552874d2074ac48ea4b834d61c54e1b6971be3 Mon Sep 17 00:00:00 2001 From: Erik Andersen Date: Sun, 23 Jan 2000 01:34:05 +0000 Subject: Some busybox updates. You no longer _have_ to put a "-" in front of tar options, logger is better behaved and has a "-t" option now. init now supports the kernel chroot patch, so you can chroot to a new device and umount the old root. -Erik --- archival/tar.c | 133 +++++++++++++++++++++++++++------------------------------ 1 file changed, 62 insertions(+), 71 deletions(-) (limited to 'archival') diff --git a/archival/tar.c b/archival/tar.c index 5c407864f..adae6c94c 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -108,9 +108,7 @@ typedef struct { */ static int listFlag; static int extractFlag; -#ifdef BB_FEATURE_TAR_CREATE static int createFlag; -#endif static int verboseFlag; static int tostdoutFlag; @@ -185,9 +183,7 @@ extern int tar_main (int argc, char **argv) errorFlag = FALSE; extractFlag = FALSE; -#ifdef BB_FEATURE_TAR_CREATE createFlag = FALSE; -#endif listFlag = FALSE; verboseFlag = FALSE; tostdoutFlag = FALSE; @@ -199,90 +195,85 @@ extern int tar_main (int argc, char **argv) /* * Parse the options. */ - if (**argv == '-') { + if (**argv == '-') options = (*argv++) + 1; - argc--; - for (; *options; options++) { - switch (*options) { - case 'f': - if (tarName != NULL) { - fprintf (stderr, "Only one 'f' option allowed\n"); - - exit (FALSE); - } - - tarName = *argv++; - argc--; - - break; - - case 't': - listFlag = TRUE; - break; - - case 'x': - extractFlag = TRUE; - break; -#ifdef BB_FEATURE_TAR_CREATE - case 'c': - createFlag = TRUE; - break; -#else - case 'c': - fprintf (stderr, "This version of tar was not compiled with tar creation support.\n" ); - - exit (FALSE); -#endif - - case 'v': - verboseFlag = TRUE; - break; - - case 'O': - tostdoutFlag = TRUE; - break; - - case '-': - usage( tar_usage); - break; + else + options = (*argv++); + argc--; - default: - fprintf (stderr, "Unknown tar flag '%c'\n" - "Try `tar --help' for more information\n", - *options); + for (; *options; options++) { + switch (*options) { + case 'f': + if (tarName != NULL) { + fprintf (stderr, "Only one 'f' option allowed\n"); exit (FALSE); } - } - } - /* - * Validate the options. - */ - if (extractFlag + listFlag -#ifdef BB_FEATURE_TAR_CREATE - + createFlag -#endif - != (TRUE+FALSE+FALSE)) { - fprintf (stderr, - "Exactly one of 'c', 'x' or 't' must be specified\n"); - - exit (FALSE); + tarName = *argv++; + argc--; + + break; + + case 't': + if (extractFlag == TRUE || createFlag == TRUE ) + goto flagError; + listFlag = TRUE; + break; + + case 'x': + if (listFlag == TRUE || createFlag == TRUE ) + goto flagError; + extractFlag = TRUE; + break; + case 'c': + if (extractFlag == TRUE || listFlag == TRUE) + goto flagError; + createFlag = TRUE; + break; + + case 'v': + verboseFlag = TRUE; + break; + + case 'O': + tostdoutFlag = TRUE; + break; + + case '-': + usage( tar_usage); + break; + + default: + fprintf (stderr, "Unknown tar flag '%c'\n" + "Try `tar --help' for more information\n", + *options); + exit (FALSE); + } } /* * Do the correct type of action supplying the rest of the * command line arguments as the list of files to process. */ -#ifdef BB_FEATURE_TAR_CREATE - if (createFlag==TRUE) + if (createFlag==TRUE) { +#ifndef BB_FEATURE_TAR_CREATE + fprintf (stderr, "This version of tar was not compiled with tar creation support.\n" ); + exit (FALSE); +#else writeTarFile (argc, argv); - else #endif + } else { readTarFile (argc, argv); - if (errorFlag==TRUE) + } + if (errorFlag==TRUE) { fprintf (stderr, "\n"); + } exit (!errorFlag); + +flagError: + fprintf (stderr, "Exactly one of 'c', 'x' or 't' must be specified\n"); + exit (FALSE); } -- cgit v1.2.3