aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-11-12 13:22:24 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-11-12 13:22:24 +0000
commitc021cb08b58dee7480fe6035d8ac00f0dbe83188 (patch)
tree818cd62174f60f4a4647b6bbcea27a1ca1029031
parent2598f761bb526afd8ec0de06071fcd6f1a897cd5 (diff)
downloadbusybox-c021cb08b58dee7480fe6035d8ac00f0dbe83188.tar.gz
- add support for seq -s <separator>
-rw-r--r--coreutils/seq.c13
-rw-r--r--include/usage.h5
2 files changed, 12 insertions, 6 deletions
diff --git a/coreutils/seq.c b/coreutils/seq.c
index 899cd696b..cf856bf04 100644
--- a/coreutils/seq.c
+++ b/coreutils/seq.c
@@ -16,8 +16,10 @@ int seq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int seq_main(int argc, char **argv)
{
double last, increment, i;
- enum { OPT_w = 1 };
- unsigned opt = getopt32(argv, "+w");
+ enum { OPT_w = 1, OPT_s };
+ const char *sep = "\n";
+ bool is_consecutive = 0;
+ unsigned opt = getopt32(argv, "+ws:", &sep);
unsigned width = 0;
argc -= optind;
@@ -39,9 +41,12 @@ int seq_main(int argc, char **argv)
/* You should note that this is pos-5.0.91 semantics, -- FK. */
while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
- printf("%0*g\n", width, i);
+ if (is_consecutive++) {
+ printf("%s", sep);
+ }
+ printf("%0*g", width, i);
i += increment;
}
-
+ bb_putchar('\n');
return fflush(stdout);
}
diff --git a/include/usage.h b/include/usage.h
index 4360edba6..f9b6aca1b 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -3594,12 +3594,13 @@
"\nOther options are silently ignored; -oi is implied" \
#define seq_trivial_usage \
- "[-w] [first [increment]] last"
+ "[-w] [-s separator] [first [increment]] last"
#define seq_full_usage "\n\n" \
"Print numbers from FIRST to LAST, in steps of INCREMENT.\n" \
"FIRST, INCREMENT default to 1\n" \
"\nArguments:" \
- "\n -w Pad to last with leading zeros" \
+ "\n -w Pad to last with leading zeros" \
+ "\n -s <string> Use string separator" \
"\n LAST" \
"\n FIRST LAST" \
"\n FIRST INCREMENT LAST" \