Jim Meyering <[EMAIL PROTECTED]> writes: > Andreas Schwab <[EMAIL PROTECTED]> wrote: >> Bruce Korb <[EMAIL PROTECTED]> writes: >> >>> Yep. That's the reason for the "compare-" prefix. I didn't like >>> ``--compare-version-sort'' for some sort of reason, too. Ultimately, >>> someone pick another name if "compare-version" is aesthetically bad. >> >> How about making it --sort=KEYWORD, with KEYWORD in >> {general-numeric,month,numeric,random,version}? > > I like it.
Here's a patch to add --sort. Andreas. 2008-02-09 Andreas Schwab <[EMAIL PROTECTED]> Add --sort option. * src/sort.c (SORT_OPTION): New enum. (sort_args, sort_types): Define. (usage, long_options, main): New option --sort. diff --git a/src/sort.c b/src/sort.c index 1183fc5..1942670 100644 --- a/src/sort.c +++ b/src/sort.c @@ -329,6 +329,9 @@ Ordering options:\n\ -n, --numeric-sort compare according to string numerical value\n\ -R, --random-sort sort by random hash of keys\n\ --random-source=FILE get random bytes from FILE (default /dev/urandom)\n\ + --sort=WORD sort according to WORD:\n\ + general-numeric -g, month -M, numeric -N,\n\ + random -R\n\ -r, --reverse reverse the result of comparisons\n\ \n\ "), stdout); @@ -391,7 +394,8 @@ enum { CHECK_OPTION = CHAR_MAX + 1, COMPRESS_PROGRAM_OPTION, - RANDOM_SOURCE_OPTION + RANDOM_SOURCE_OPTION, + SORT_OPTION }; static char const short_options[] = "-bcCdfgik:mMno:rRsS:t:T:uy:z"; @@ -411,6 +415,7 @@ static struct option const long_options[] = {"numeric-sort", no_argument, NULL, 'n'}, {"random-sort", no_argument, NULL, 'R'}, {"random-source", required_argument, NULL, RANDOM_SOURCE_OPTION}, + {"sort", required_argument, NULL, SORT_OPTION}, {"output", required_argument, NULL, 'o'}, {"reverse", no_argument, NULL, 'r'}, {"stable", no_argument, NULL, 's'}, @@ -434,6 +439,16 @@ static char const check_types[] = }; ARGMATCH_VERIFY (check_args, check_types); +static char const *const sort_args[] = +{ + "general-numeric", "month", "numeric", "random", NULL +}; +static char const sort_types[] = +{ + 'g', 'M', 'n', 'R' +}; +ARGMATCH_VERIFY (sort_args, sort_types); + /* The set of signals that are caught. */ static sigset_t caught_signals; @@ -2902,6 +2917,9 @@ main (int argc, char **argv) files[nfiles++] = optarg; break; + case SORT_OPTION: + c = XARGMATCH ("--sort", optarg, sort_args, sort_types); + /* Fall through. */ case 'b': case 'd': case 'f': -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils