diff options
author | 2015-04-05 13:54:06 +0000 | |
---|---|---|
committer | 2015-04-05 13:54:06 +0000 | |
commit | 08edd714be3129c35f9281ad2f515812bed6eb25 (patch) | |
tree | b19d4f5e33eb7f54e92928b3a72ca6ba7b0e296d | |
parent | Don't use GH_COMMIT and GH_TAGNAME together. From Adam Wolk. (diff) | |
download | wireguard-openbsd-08edd714be3129c35f9281ad2f515812bed6eb25.tar.xz wireguard-openbsd-08edd714be3129c35f9281ad2f515812bed6eb25.zip |
Do not permute command line arguments but still support the
obsolescent "-o outfile" after input files syntax.
-rw-r--r-- | usr.bin/sort/sort.1 | 11 | ||||
-rw-r--r-- | usr.bin/sort/sort.c | 20 |
2 files changed, 24 insertions, 7 deletions
diff --git a/usr.bin/sort/sort.1 b/usr.bin/sort/sort.1 index cd0f7125ef6..41252ea0a3e 100644 --- a/usr.bin/sort/sort.1 +++ b/usr.bin/sort/sort.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sort.1,v 1.51 2015/04/01 19:56:01 millert Exp $ +.\" $OpenBSD: sort.1,v 1.52 2015/04/05 13:54:06 millert Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)sort.1 8.1 (Berkeley) 6/6/93 .\" -.Dd $Mdocdate: April 1 2015 $ +.Dd $Mdocdate: April 5 2015 $ .Dt SORT 1 .Os .Sh NAME @@ -582,6 +582,13 @@ Some are provided for compatibility with GNU .Nm , others are specific to this implementation. .Pp +The historic practice of allowing the +.Fl o +option to appear after the +.Ar file +is supported for compatibility with older versions of +.Nm . +.Pp The historic key notations .Cm \(pl Ns Ar pos1 and diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c index 4226bb229f4..fa7abb9d753 100644 --- a/usr.bin/sort/sort.c +++ b/usr.bin/sort/sort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sort.c,v 1.77 2015/04/03 12:52:48 millert Exp $ */ +/* $OpenBSD: sort.c,v 1.78 2015/04/05 13:54:06 millert Exp $ */ /*- * Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org> @@ -53,7 +53,12 @@ #include "file.h" #include "sort.h" -#define OPTIONS "bCcdfgHhik:Mmno:RrS:st:T:uVz" +#ifdef GNUSORT_COMPATIBILITY +# define PERMUTE "" +#else +# define PERMUTE "+" +#endif +#define OPTIONS PERMUTE"bCcdfgHhik:Mmno:RrS:st:T:uVz" static bool need_random; static const char *random_source; @@ -859,6 +864,7 @@ main(int argc, char *argv[]) char *outfile, *real_outfile, *sflag; int c; size_t i; + struct sort_mods *sm = &default_sort_mods_object; bool mef_flags[NUMBER_OF_MUTUALLY_EXCLUSIVE_FLAGS] = { false, false, false, false, false, false }; @@ -866,8 +872,6 @@ main(int argc, char *argv[]) real_outfile = NULL; sflag = NULL; - struct sort_mods *sm = &default_sort_mods_object; - init_tmp_files(); set_signal_handler(); @@ -1038,10 +1042,16 @@ main(int argc, char *argv[]) } } } - argc -= optind; argv += optind; +#ifndef GNUSORT_COMPATIBILITY + if (argc > 2 && strcmp(argv[argc - 2], "-o") == 0) { + outfile = argv[argc - 1]; + argc -= 2; + } +#endif + if (sort_opts_vals.cflag && argc > 1) errx(2, "only one input file is allowed with the -%c flag", sort_opts_vals.csilentflag ? 'C' : 'c'); |