Skip to content

Instantly share code, notes, and snippets.

@veganstraightedge
Last active August 30, 2018 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veganstraightedge/20f1ed22cffa1d4b08ce9dc8d47edf30 to your computer and use it in GitHub Desktop.
Save veganstraightedge/20f1ed22cffa1d4b08ce9dc8d47edf30 to your computer and use it in GitHub Desktop.
These lines of commands work when run directly in Terminal, but fail when run as the contents of a file.
#!/bin/sh
# this test case script assumes that you are on macOS and have Homebrew (brew) installed
set -e
brew install nvm
mkdir -p ~/.nvm
export NVM_DIR="$HOME/.nvm"
source "/usr/local/opt/nvm/nvm.sh"
nvm install v6.10.3
nvm use --delete-prefix v6.10.3

When run as a script:

$ ./bootstrap.sh 
Warning: nvm 0.33.11 is already installed and up-to-date
To reinstall 0.33.11, run `brew reinstall nvm`
Downloading and installing node v6.10.3...
Downloading https://nodejs.org/dist/v6.10.3/node-v6.10.3-darwin-x64.tar.xz...
######################################################################## 100.0%
Binary download failed, trying source. 
$ 

When run from the prompt:

$ set -e
$ 
$ brew install nvm
Warning: nvm 0.33.11 is already installed and up-to-date
To reinstall 0.33.11, run `brew reinstall nvm`
$ 
$ mkdir -p ~/.nvm
$ export NVM_DIR="$HOME/.nvm"
$ source "/usr/local/opt/nvm/nvm.sh"
$ 
$ nvm install v6.10.3
Downloading and installing node v6.10.3...
Downloading https://nodejs.org/dist/v6.10.3/node-v6.10.3-darwin-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Creating default alias: default -> v6.10.3
$ nvm use --delete-prefix v6.10.3     
Now using node v6.10.3 (npm v3.10.10)
$  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment