diff --git a/CHANGELOG.md b/CHANGELOG.md index 09a689a..a5fea66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Versioning complies with [semantic versioning (semver)](http://semver.org/). +* **[v0.1.8](https://github.com/mklement0/n-install/compare/v0.1.7...v0.1.8)** (2015-12-18): + * [enhancement] Added runtime check to ensure that the Bash version running `n-install` is 3.2 or higher. + * **[v0.1.7](https://github.com/mklement0/n-install/compare/v0.1.6...v0.1.7)** (2015-11-23): * [doc] Removed references to io.js, now the project has merged with Node.js. * [doc] Added better tip for simulating an interactive environment for reloading a Bash initialization file. diff --git a/README.md b/README.md index c44c32e..5dd2daa 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ DESCRIPTION For more information, see http://git.io/n-install-repo PREREQUISITES - bash ... to run this script and n itself. + bash 3.2 or higher ... to run this script and n itself. curl ... to download helper scripts from GitHub and run n itself. git ... to clone n's GitHub repository and update n later. GNU make ... to run n's installation procedure. @@ -272,6 +272,9 @@ Versioning complies with [semantic versioning (semver)](http://semver.org/). +* **[v0.1.8](https://github.com/mklement0/n-install/compare/v0.1.7...v0.1.8)** (2015-12-18): + * [enhancement] Added runtime check to ensure that the Bash version running `n-install` is 3.2 or higher. + * **[v0.1.7](https://github.com/mklement0/n-install/compare/v0.1.6...v0.1.7)** (2015-11-23): * [doc] Removed references to io.js, now the project has merged with Node.js. * [doc] Added better tip for simulating an interactive environment for reloading a Bash initialization file. diff --git a/bin/n-install b/bin/n-install index 0dc6a4c..7fbbe36 100755 --- a/bin/n-install +++ b/bin/n-install @@ -1,12 +1,15 @@ #!/usr/bin/env bash -# !! CAVEAT (hypothetical, for now, because n as of 1.3.0 doesn't support FreeBSD, given that binary Node.js packages aren't available for it): -# !! On FreeBSD, process substitution (<(...)) is by default NOT ENABLED- AVOID PROCESS SUBSTITUTIONS. +# !! CAVEAT: +# !! On FreeBSD, process substitution (<(...)) is by default NOT ENABLED - AVOID PROCESS SUBSTITUTIONS IN THIS SCRIPT. +# !! (hypothetical, for now, because n as of 1.3.0 doesn't support FreeBSD, given that binary Node.js packages aren't available for it) # # Script-global constants # +kMIN_BASH_VERSION='3.2' # due to use of =~, we require at least 3.2 + ##### IMPORTANT: These names must, at least in part, be kept in sync with their counterparts in 'n-update' and 'n-uninstall'. kINSTALLER_NAME=n-install # This script's name; note that since we'll typically be running via curl directly from GitHub, using $(basename "$BASH_SOURCE") to determine the name is not an option. kTHIS_REPO_URL='http://git.io/n-install-repo' # This script's source repository - SHORT, git.io-based form. @@ -40,6 +43,22 @@ kHELPER_SCRIPT_URLS=( # BEGIN: Helper functions # +# SYNOPIS +# isMinBashVersion +# DESCRIPTION +# Indicates via exit code whether the Bash version running this script meets the minimum version number specified. +# EXAMPLES +# isMinBashVersion 3.2 +# isMinBashVersion 4 +isMinBashVersion() { + local minMajor minMinor thisMajor thisMinor + IFS=. read -r minMajor minMinor <<<"$1" + [[ -z $minMinor ]] && minMinor=0 + thisMajor=${BASH_VERSINFO[0]} + thisMinor=${BASH_VERSINFO[1]} + (( thisMajor > minMajor || (thisMajor == minMajor && thisMinor >= minMinor) )) +} + # SYNOPSIS # echoColored colorNum [text...] # DESCRIPTION @@ -380,11 +399,13 @@ parseSemVer() { # MAIN SCRIPT BODY # +isMinBashVersion "$kMIN_BASH_VERSION" || die "This script requires Bash $kMIN_BASH_VERSION or higher." + unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[[ $1 == '--version' ]] && { ver='v0.1.7'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } +[[ $1 == '--version' ]] && { ver='v0.1.8'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } # !! AS OF n 1.3.0, n ITSELF ONLY WORKS WITH curl, NOT ALSO WITH wget. # !! Once n also supports wget, mention wget as an alternative in the help text. diff --git a/bin/n-uninstall b/bin/n-uninstall index 631f8a9..99c371d 100755 --- a/bin/n-uninstall +++ b/bin/n-uninstall @@ -208,7 +208,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[ "$1" = '--version' ] && { ver='v0.1.7'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } +[ "$1" = '--version' ] && { ver='v0.1.8'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } # Command-line help. if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then diff --git a/bin/n-update b/bin/n-update index 8863a5b..8baca73 100755 --- a/bin/n-update +++ b/bin/n-update @@ -124,7 +124,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[ "$1" = '--version' ] && { ver='v0.1.7'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } +[ "$1" = '--version' ] && { ver='v0.1.8'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } # Command-line help. if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then diff --git a/package.json b/package.json index 5b39da1..fe9631b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "n-install", "description": "installs n, the Node.js version manager, without needing to install Node.js first", "private": true, - "version": "0.1.7", + "version": "0.1.8", "os": [ "darwin", "linux"