mirror of
https://github.com/sheumann/hush.git
synced 2025-01-13 21:31:51 +00:00
- add support for seq -s <separator>
This commit is contained in:
parent
2598f761bb
commit
c021cb08b5
@ -16,8 +16,10 @@ int seq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
|||||||
int seq_main(int argc, char **argv)
|
int seq_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
double last, increment, i;
|
double last, increment, i;
|
||||||
enum { OPT_w = 1 };
|
enum { OPT_w = 1, OPT_s };
|
||||||
unsigned opt = getopt32(argv, "+w");
|
const char *sep = "\n";
|
||||||
|
bool is_consecutive = 0;
|
||||||
|
unsigned opt = getopt32(argv, "+ws:", &sep);
|
||||||
unsigned width = 0;
|
unsigned width = 0;
|
||||||
|
|
||||||
argc -= optind;
|
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. */
|
/* You should note that this is pos-5.0.91 semantics, -- FK. */
|
||||||
while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
|
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;
|
i += increment;
|
||||||
}
|
}
|
||||||
|
bb_putchar('\n');
|
||||||
return fflush(stdout);
|
return fflush(stdout);
|
||||||
}
|
}
|
||||||
|
@ -3594,12 +3594,13 @@
|
|||||||
"\nOther options are silently ignored; -oi is implied" \
|
"\nOther options are silently ignored; -oi is implied" \
|
||||||
|
|
||||||
#define seq_trivial_usage \
|
#define seq_trivial_usage \
|
||||||
"[-w] [first [increment]] last"
|
"[-w] [-s separator] [first [increment]] last"
|
||||||
#define seq_full_usage "\n\n" \
|
#define seq_full_usage "\n\n" \
|
||||||
"Print numbers from FIRST to LAST, in steps of INCREMENT.\n" \
|
"Print numbers from FIRST to LAST, in steps of INCREMENT.\n" \
|
||||||
"FIRST, INCREMENT default to 1\n" \
|
"FIRST, INCREMENT default to 1\n" \
|
||||||
"\nArguments:" \
|
"\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 LAST" \
|
||||||
"\n FIRST LAST" \
|
"\n FIRST LAST" \
|
||||||
"\n FIRST INCREMENT LAST" \
|
"\n FIRST INCREMENT LAST" \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user