1) bb_opt_complementaly -> bb_opt_complementally
2) better support long options 3) new flag '!' for bb_opt_complementally: produce bb_show_usage() if BB_GETOPT_ERROR internally
This commit is contained in:
@@ -295,7 +295,7 @@ extern int cut_main(int argc, char **argv)
|
||||
unsigned long opt;
|
||||
char *sopt, *sdopt;
|
||||
|
||||
bb_opt_complementaly = "b~bcf:c~bcf:f~bcf";
|
||||
bb_opt_complementally = "b~bcf:c~bcf:f~bcf";
|
||||
opt = bb_getopt_ulflags(argc, argv, optstring, &sopt, &sopt, &sopt, &sdopt);
|
||||
part = opt & (OPT_BYTE_FLGS|OPT_CHAR_FLGS|OPT_FIELDS_FLGS);
|
||||
if(part == 0)
|
||||
|
@@ -152,7 +152,7 @@ int date_main(int argc, char **argv)
|
||||
#else
|
||||
# define GETOPT_ISOFMT
|
||||
#endif
|
||||
bb_opt_complementaly = "d~ds:s~ds";
|
||||
bb_opt_complementally = "!d~ds:s~ds";
|
||||
opt = bb_getopt_ulflags(argc, argv, "Rs:ud:r:" GETOPT_ISOFMT,
|
||||
&date_str, &date_str, &filename
|
||||
#ifdef CONFIG_FEATURE_DATE_ISOFMT
|
||||
@@ -165,8 +165,6 @@ int date_main(int argc, char **argv)
|
||||
bb_error_msg_and_die(bb_msg_memory_exhausted);
|
||||
}
|
||||
use_arg = opt & DATE_OPT_DATE;
|
||||
if(opt & BB_GETOPT_ERROR)
|
||||
bb_show_usage();
|
||||
#ifdef CONFIG_FEATURE_DATE_ISOFMT
|
||||
if(opt & DATE_OPT_TIMESPEC) {
|
||||
if (!isofmt_arg) {
|
||||
|
@@ -62,7 +62,7 @@ extern int df_main(int argc, char **argv)
|
||||
const char *disp_units_hdr = hdr_1k;
|
||||
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
bb_opt_complementaly = "h-km:k-hm:m-hk";
|
||||
bb_opt_complementally = "h-km:k-hm:m-hk";
|
||||
opt = bb_getopt_ulflags(argc, argv, "hmk");
|
||||
if(opt & 1) {
|
||||
df_disp_hr = 0;
|
||||
|
@@ -191,7 +191,7 @@ int du_main(int argc, char **argv)
|
||||
* ignore -a. This is consistent with -s being equivalent to -d 0.
|
||||
*/
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
bb_opt_complementaly = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
|
||||
bb_opt_complementally = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
|
||||
opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
|
||||
if((opt & (1 << 9))) {
|
||||
/* -h opt */
|
||||
@@ -206,7 +206,7 @@ int du_main(int argc, char **argv)
|
||||
disp_hr = KILOBYTE;
|
||||
}
|
||||
#else
|
||||
bb_opt_complementaly = "H-L:L-H:s-d:d-s";
|
||||
bb_opt_complementally = "H-L:L-H:s-d:d-s";
|
||||
opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
|
||||
#if !defined CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
|
||||
if((opt & (1 << 2))) {
|
||||
|
@@ -65,7 +65,7 @@ extern int env_main(int argc, char** argv)
|
||||
llist_t *unset_env = NULL;
|
||||
extern char **environ;
|
||||
|
||||
bb_opt_complementaly = "u*";
|
||||
bb_opt_complementally = "u*";
|
||||
bb_applet_long_options = env_long_options;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "+iu:", &unset_env);
|
||||
|
@@ -61,12 +61,11 @@ extern int id_main(int argc, char **argv)
|
||||
unsigned long flags;
|
||||
short status;
|
||||
|
||||
bb_opt_complementaly = "u~g:g~u";
|
||||
bb_opt_complementally = "!u~g:g~u";
|
||||
flags = bb_getopt_ulflags(argc, argv, "rnug");
|
||||
|
||||
if ((flags & BB_GETOPT_ERROR)
|
||||
/* Don't allow -n -r -nr */
|
||||
|| (flags <= 3 && flags > 0)
|
||||
if ((flags <= 3 && flags > 0)
|
||||
/* Don't allow more than one username */
|
||||
|| (argc > optind + 1))
|
||||
bb_show_usage();
|
||||
|
@@ -64,15 +64,10 @@ extern int install_main(int argc, char **argv)
|
||||
int i;
|
||||
|
||||
bb_applet_long_options = install_long_options;
|
||||
bb_opt_complementaly = "s~d:d~s";
|
||||
bb_opt_complementally = "!s~d:d~s";
|
||||
/* -c exists for backwards compatability, its needed */
|
||||
flags = bb_getopt_ulflags(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */
|
||||
|
||||
/* Check valid options were given */
|
||||
if(flags & BB_GETOPT_ERROR) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
/* preserve access and modification time, this is GNU behaviour, BSD only preserves modification time */
|
||||
if (flags & INSTALL_OPT_PRESERVE_TIME) {
|
||||
copy_flags |= FILEUTILS_PRESERVE_STATUS;
|
||||
|
@@ -56,7 +56,7 @@ extern int mv_main(int argc, char **argv)
|
||||
int status = 0;
|
||||
|
||||
bb_applet_long_options = mv_long_options;
|
||||
bb_opt_complementaly = "f-i:i-f";
|
||||
bb_opt_complementally = "f-i:i-f";
|
||||
flags = bb_getopt_ulflags(argc, argv, "fi");
|
||||
if (optind + 2 > argc) {
|
||||
bb_show_usage();
|
||||
|
@@ -38,7 +38,7 @@ extern int rm_main(int argc, char **argv)
|
||||
int flags = 0;
|
||||
unsigned long opt;
|
||||
|
||||
bb_opt_complementaly = "f-i:i-f";
|
||||
bb_opt_complementally = "f-i:i-f";
|
||||
opt = bb_getopt_ulflags(argc, argv, "fiRr");
|
||||
if(opt & 1)
|
||||
flags |= FILEUTILS_FORCE;
|
||||
|
Reference in New Issue
Block a user