Opened 5 years ago
Closed 4 years ago
#60051 closed defect (fixed)
gildas @202002a: sort: invalid option -- V
Reported by: | ryandesign (Ryan Carsten Schmidt) | Owned by: | bardeau |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.6.2 |
Keywords: | Cc: | ||
Port: | gildas |
Description
The first thing printed in the build phase is:
sort: invalid option -- V Try `sort --help' for more information. sort: invalid option -- V Try `sort --help' for more information. sort: invalid option -- V Try `sort --help' for more information. sort: invalid option -- V Try `sort --help' for more information.
Change History (6)
comment:2 follow-up: 3 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)
macOS sort
has a -V
option on High Sierra and newer but not on El Capitan and older. I didn't test Sierra. I'm told busybox's sort
also doesn't have -V
. So it's not portable to use that.
If you don't care about portability, you can add a dependency on port:coreutils and use ${prefix}/bin/gsort
instead of sort
. It does support -V
.
There are many other potential solutions to this problem of varying portability and correctness. I haven't tried them myself but maybe you'll see a method in there that you like.
comment:3 follow-up: 4 Changed 4 years ago by bardeau
Replying to ryandesign:
If you don't care about portability, you can add a dependency on port:coreutils and use
${prefix}/bin/gsort
instead ofsort
. It does support-V
.
What is the proper way to to invoke gsort from my shell script? Is ${prefix} supposed to be a valid environment variable? It does not seem:
/opt/local/var/macports/build/_opt_local_var_macports_sources_github.com_macports_macports-ports_science_gildas/gildas/work/gildas-src-jun20b/admin/define-system.sh: line 28: /bin/gsort: No such file or directory
Isn't there a configure.* keyword I could use for reinplacement?
There are many other potential solutions to this problem of varying portability and correctness. I haven't tried them myself but maybe you'll see a method in there that you like.
I precisely used one of the method proposed on this page (verle-verlt). A lot of methods contain bashisms which are not portable (in particular to dash or zsh). The verlt-verle is the softest solution I could find, at the cost of depending on a sort -V implementation.
comment:4 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)
Replying to bardeau:
Replying to ryandesign:
If you don't care about portability, you can add a dependency on port:coreutils and use
${prefix}/bin/gsort
instead ofsort
. It does support-V
.What is the proper way to to invoke gsort from my shell script? Is ${prefix} supposed to be a valid environment variable? It does not seem:
/opt/local/var/macports/build/_opt_local_var_macports_sources_github.com_macports_macports-ports_science_gildas/gildas/work/gildas-src-jun20b/admin/define-system.sh: line 28: /bin/gsort: No such file or directoryIsn't there a configure.* keyword I could use for reinplacement?
prefix
is a Tcl variable. If you need it outside of Tcl, for example in a source code file, you add a patchfile that puts a @PREFIX@
placeholder into the file in the right place, and then you replace the placeholder with the variable's value like this:
post-patch { reinplace -W ${worksrcpath} "s|@PREFIX@|${prefix}|g" somefile.sh someotherfile.sh }
There are many other potential solutions to this problem of varying portability and correctness. I haven't tried them myself but maybe you'll see a method in there that you like.
I precisely used one of the method proposed on this page (verle-verlt). A lot of methods contain bashisms which are not portable (in particular to dash or zsh). The verlt-verle is the softest solution I could find, at the cost of depending on a sort -V implementation.
As I said, the proposals are of varying portability. :) sort -V
isn't portable.
comment:5 Changed 4 years ago by bardeau
I have made a bug fix and a pull request to solve this issue.
comment:6 Changed 4 years ago by bardeau
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This comes from an attempt to create a shell utility which is able to indicate if a program version is lower than some reference version. Namely:
used as e.g. with some plain numbers:
In the past we used the syntax
"<" provides lexicographical comparison, which is valid up to versions 9.9.9. Unfortunately, zsh does not behave correctly with the later syntax. Note that zsh is now the default user shell under macOS. Choice has been made to use the functions shown on top, which make use of "sort -V" (sort by version number). My tests have shown a good support on a variety of OS, including Catalina 10.15.2, but it seems it is not as portable as I expected.
Last but not least, I need a syntax compatible with bash, dash, and zsh. For the time being I have no good solution.