summaryrefslogtreecommitdiff
path: root/src/sort.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-09-07 05:09:24 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-09-07 05:09:24 +0000
commit0cd2d8a70e528c6f4dc4f6650e819a7d5a3d177d (patch)
tree1c051658177c9893936013405991f0a77d54149d /src/sort.c
parent47b9873ada574d0233954826247fd54653cfbd26 (diff)
downloadcoreutils-0cd2d8a70e528c6f4dc4f6650e819a7d5a3d177d.tar.xz
(main): Emulate Solaris 8 and 9 "sort -y", so that
"sort -y abc" is like "sort abc" whereas "sort -y 100" is like plain "sort".
Diffstat (limited to 'src/sort.c')
-rw-r--r--src/sort.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/sort.c b/src/sort.c
index 014beb7c5..a9cf0c191 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -2472,9 +2472,23 @@ main (int argc, char **argv)
break;
case 'y':
- /* Accept and ignore e.g. -y0 for compatibility with Solaris
- 2.x through Solaris 7. -y is marked as obsolete starting
- with Solaris 8. */
+ /* Accept and ignore e.g. -y0 for compatibility with Solaris 2.x
+ through Solaris 7. It is also accepted by many non-Solaris
+ "sort" implementations, e.g., AIX 5.2, HP-UX 11i v2, IRIX 6.5.
+ -y is marked as obsolete starting with Solaris 8 (1999), but is
+ still accepted as of Solaris 10 prerelease (2004).
+
+ Solaris 2.5.1 "sort -y 100" reads the input file "100", but
+ emulate Solaris 8 and 9 "sort -y 100" which ignores the "100",
+ and which in general ignores the argument after "-y" if it
+ consists entirely of digits (it can even be empty). */
+ if (!optarg && optind != argc)
+ {
+ char const *p;
+ for (p = argv[optind]; ISDIGIT (*p); p++)
+ continue;
+ optind += !*p;
+ }
break;
case 'z':