diff options
author | Denis Vlasenko | 2007-03-10 17:22:14 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-03-10 17:22:14 +0000 |
commit | be644a81e91bcfacfc8948a39e5184fa6cba663e (patch) | |
tree | 7158aa9443a54b29464d83305a85c5aafe9a9917 /editors | |
parent | 49622d784672bf2f7b2fe80589714cdef5adde0c (diff) | |
download | busybox-be644a81e91bcfacfc8948a39e5184fa6cba663e.zip busybox-be644a81e91bcfacfc8948a39e5184fa6cba663e.tar.gz |
awk: support multiple -v options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/awk.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/editors/awk.c b/editors/awk.c index d0b03c3..a18025e 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -2648,7 +2648,8 @@ int awk_main(int argc, char **argv); int awk_main(int argc, char **argv) { unsigned opt; - char *opt_F, *opt_v, *opt_W; + char *opt_F, *opt_W; + llist_t *opt_v = NULL; int i, j, flen; var *v; var tv; @@ -2701,12 +2702,16 @@ int awk_main(int argc, char **argv) } free(s); } - + opt_complementary = "v::"; opt = getopt32(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W); argv += optind; argc -= optind; if (opt & 0x1) setvar_s(V[FS], opt_F); // -F - if (opt & 0x2) if (!is_assignment(opt_v)) bb_show_usage(); // -v + opt_v = llist_rev(opt_v); + while (opt_v) { /* -v */ + if (!is_assignment(llist_pop(&opt_v))) + bb_show_usage(); + } if (opt & 0x4) { // -f char *s = s; /* die, gcc, die */ FILE *from_file = afopen(programname, "r"); |