diff options
| author | Michael Heimpold <mhei@heimpold.de> | 2017-03-24 21:36:39 +0100 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2017-03-27 20:32:58 -0700 |
| commit | 73c8452e83d70300a4d627d004be1be4b3ff1019 (patch) | |
| tree | 41652c7b01f67ec65ad99f0aecd8e8c694393381 /src/split.c | |
| parent | md5sum,b2sum,sha*sum: don't erroneously trigger BSD reversed mode (diff) | |
| download | coreutils-73c8452e83d70300a4d627d004be1be4b3ff1019.tar.gz coreutils-73c8452e83d70300a4d627d004be1be4b3ff1019.zip | |
split: add new --hex-suffixes option
* doc/coreutils.texi (split invocation): Document the new option.
* src/split.c (usage): Likewise.
(main): Process the new option much like --numeric-suffixes,
but with an adjusted alphabet.
* tests/split/numeric.sh: Refactor to support --hex mode.
* NEWS: Mention the new feature.
Diffstat (limited to 'src/split.c')
| -rw-r--r-- | src/split.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/split.c b/src/split.c index 01f97afad..a6fbd1d50 100644 --- a/src/split.c +++ b/src/split.c @@ -141,6 +141,7 @@ static struct option const longopts[] = {"additional-suffix", required_argument, NULL, ADDITIONAL_SUFFIX_OPTION}, {"numeric-suffixes", optional_argument, NULL, 'd'}, + {"hex-suffixes", optional_argument, NULL, 'x'}, {"filter", required_argument, NULL, FILTER_OPTION}, {"verbose", no_argument, NULL, VERBOSE_OPTION}, {"separator", required_argument, NULL, 't'}, @@ -242,6 +243,8 @@ default size is 1000 lines, and default PREFIX is 'x'.\n\ -d use numeric suffixes starting at 0, not alphabetic\n\ --numeric-suffixes[=FROM] same as -d, but allow setting the start value\ \n\ + -x use hex suffixes starting at 0, not alphabetic\n\ + --hex-suffixes[=FROM] same as -x, but allow setting the start value\n\ -e, --elide-empty-files do not generate empty output files with '-n'\n\ --filter=COMMAND write to shell COMMAND; file name is $FILE\n\ -l, --lines=NUMBER put NUMBER lines/records per output file\n\ @@ -1322,7 +1325,7 @@ main (int argc, char **argv) int this_optind = optind ? optind : 1; char *slash; - c = getopt_long (argc, argv, "0123456789C:a:b:del:n:t:u", + c = getopt_long (argc, argv, "0123456789C:a:b:del:n:t:ux", longopts, NULL); if (c == -1) break; @@ -1461,13 +1464,19 @@ main (int argc, char **argv) break; case 'd': - suffix_alphabet = "0123456789"; + case 'x': + if (c == 'd') + suffix_alphabet = "0123456789"; + else + suffix_alphabet = "0123456789abcdef"; if (optarg) { if (strlen (optarg) != strspn (optarg, suffix_alphabet)) { error (0, 0, - _("%s: invalid start value for numerical suffix"), + (c == 'd') ? + _("%s: invalid start value for numerical suffix") : + _("%s: invalid start value for hexadecimal suffix"), quote (optarg)); usage (EXIT_FAILURE); } |
