robertpeteuil / terraform-installer

Installer for HashiCorp Terraform - Automatic Download, Extract and Install of Latest or Specific Version

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sort --version-sort not supported on OSX 10.10

keen99 opened this issue · comments

this makes heavy use of sort --version-sort which isn't a thing on osx (at least not 10.9, 10.10, and I dont really expect that to have changed in later releases...)

additionally, there's no handling (trap, set -e, something) around failed calls to external tools, so the script just plows right on through the error producing who knows what results....

%% ./terraform-install.sh -h
sort: unrecognized option `--version-sort'
Try `sort --help' for more information.
Download and Install Terraform - Latest Version unless '-i' specified

usage: terraform-install.sh [-i VERSION] [-a] [-c] [-h] [-v]
     -i VERSION	: specify version to install in format '' (OPTIONAL)
     -a		: automatically use sudo to install to /usr/local/bin
     -c		: leave binary in working directory (for CI/DevOps use)
     -h		: help
     -v		: display terraform-install.sh version

....for that matter, shouldn't help/usage trigger before trying to curl a bunch of things? :)

Thank you for sharing this feedback and pointed out these issues!

While investigating this, I discovered a different issue in the version-checking algorithms.

I'll publish an update as soon as I can.

A couple of notes:

  • The sort --version-sort compatibility occurs on systems with older versions of OS X that have jq installed.
    • This was utility was developed on macOS, so I definitely want to support older versions.
  • I agree that help should be displayed before running external commands. The current behavior was something that I didn't catch in a PR some time ago.
  • While it doesn't currently use set -e, this error would have been caught when the download URL was verified. There are a dozen or so error checks and validations.
    • checks for installed dependencies
    • verifies the calculated download URL, on failure it displaying all calculated values
    • validates download, extraction and every file-system command
    • verifies the SHA of the download against the SHA published by Hashicorp

These issues have been addressed in 1.5.0

👍 thanks!