From 80f94f33956a758444f6c6918036b41288cd4da9 Mon Sep 17 00:00:00 2001
From: Julien Reichardt <mi@jrei.ch>
Date: Tue, 2 Jan 2018 14:52:14 +0100
Subject: [PATCH] Change from `bash` to `sh` (#5468)

* Removes bash as a dependency
* Better compliance to POSIX

diff --git a/Makefile b/Makefile
index a4b2281dc1..a6b2f5d1d4 100644
--- a/Makefile
+++ b/Makefile
@@ -29,8 +29,8 @@ SOURCES := $(shell find src -name '*.cr')
 SPEC_SOURCES := $(shell find spec -name '*.cr')
 FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static )
 SPEC_FLAGS := $(if $(verbose),-v )$(if $(junit_output),--junit_output $(junit_output) )
-EXPORTS := $(if $(release),,CRYSTAL_CONFIG_PATH=`pwd`/src)
-SHELL = bash
+EXPORTS := $(if $(release),,CRYSTAL_CONFIG_PATH=$PWD/src)
+SHELL = sh
 LLVM_CONFIG_FINDER := \
   [ -n "$(LLVM_CONFIG)" ] && command -v "$(LLVM_CONFIG)" || \
   command -v llvm-config-4.0 || command -v llvm-config40 || \
@@ -118,7 +118,7 @@ $(O)/crystal: $(DEPS) $(SOURCES)
 	$(BUILD_PATH) $(EXPORTS) ./bin/crystal build $(FLAGS) -o $@ src/compiler/crystal.cr -D without_openssl -D without_zlib
 
 $(LLVM_EXT_OBJ): $(LLVM_EXT_DIR)/llvm_ext.cc
-	$(CXX) -c $(CXXFLAGS) -o $@ $< `$(LLVM_CONFIG) --cxxflags`
+	$(CXX) -c $(CXXFLAGS) -o $@ $< $(shell $(LLVM_CONFIG) --cxxflags)
 
 $(LIB_CRYSTAL_TARGET): $(LIB_CRYSTAL_OBJS)
 	$(AR) -rcs $@ $^
diff --git a/Vagrantfile b/Vagrantfile
index 83bcf8c3ce..859f682dbf 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -15,7 +15,7 @@ Vagrant.configure("2") do |config|
       c.vm.box = "ubuntu/#{box_name}"
 
       c.vm.provision :shell, inline: %(
-        curl -s https://dist.crystal-lang.org/apt/setup.sh | bash
+        curl -s https://dist.crystal-lang.org/apt/setup.sh | sh
         apt-get install -y crystal git libgmp3-dev zlib1g-dev libedit-dev libxml2-dev libssl-dev libyaml-dev libreadline-dev g++
         curl -s https://crystal-lang.s3.amazonaws.com/llvm/llvm-3.5.0-1-linux-`uname -m`.tar.gz | tar xz -C /opt
         echo 'export LIBRARY_PATH="/opt/crystal/embedded/lib"' > /etc/profile.d/crystal.sh
diff --git a/bin/crystal b/bin/crystal
index 698ed9b2b3..c901d9b37f 100755
--- a/bin/crystal
+++ b/bin/crystal
@@ -37,7 +37,7 @@ _resolve_symlinks() {
 
     local dir_context path
     path=$(readlink -- "$1")
-    if [ $? -eq 0 ]; then
+    if [ $? = 0 ]; then
         dir_context=$(dirname -- "$1")
         _resolve_symlinks "$(_prepend_dir_context_if_necessary "$dir_context" "$path")" "$@"
     else
@@ -141,16 +141,13 @@ CRYSTAL_DIR="$CRYSTAL_ROOT/.build"
 export CRYSTAL_PATH=$CRYSTAL_ROOT/src:lib
 export CRYSTAL_HAS_WRAPPER=true
 
-if [ -x "$CRYSTAL_DIR/crystal" ]
-then
+if [ -x "$CRYSTAL_DIR/crystal" ]; then
   __warning_msg "Using compiled compiler at \`.build/crystal'"
   exec "$CRYSTAL_DIR/crystal" "$@"
-elif ! command -v crystal > /dev/null
-then
+elif ! command -v crystal > /dev/null; then
   __error_msg 'You need to have a crystal executable in your path!'
   exit 1
-elif [ "$(command -v crystal)" = "$SCRIPT_PATH" ] || [ "$(command -v crystal)" = "bin/crystal" ]
-then
+elif [ "$(command -v crystal)" = "$SCRIPT_PATH" ] || [ "$(command -v crystal)" = "bin/crystal" ]; then
   export PATH="$(remove_path_item "$(remove_path_item "$PATH" "$SCRIPT_ROOT")" "bin")"
   exec "$SCRIPT_PATH" "$@"
 else
