diff --git a/examples/script-overrides/git-extract-submodules/git-extract.sh b/examples/script-overrides/git-extract-submodules/git-extract.sh index d258de4..477865b 100644 --- a/examples/script-overrides/git-extract-submodules/git-extract.sh +++ b/examples/script-overrides/git-extract-submodules/git-extract.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script is called from lib/octocatalog-diff/catalog-util/git.rb and is used to # archive and extract a certain branch of a git repository into a target directory. diff --git a/script/fmt b/script/fmt index e130b01..2576e8b 100755 --- a/script/fmt +++ b/script/fmt @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" RUBOCOP_YML="${DIR}/.rubocop.yml" diff --git a/script/git-pre-commit b/script/git-pre-commit index 64c997f..88f4a60 100755 --- a/script/git-pre-commit +++ b/script/git-pre-commit @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script is being invoked via /.git/hooks, hence the # base directory is up two levels, not just one. diff --git a/script/octocatalog-diff-wrapper b/script/octocatalog-diff-wrapper index 8f3104b..090648a 100755 --- a/script/octocatalog-diff-wrapper +++ b/script/octocatalog-diff-wrapper @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script exists to make it easier to test alternate branches of octocatalog-diff. # It is intended as a one-for-one replacement of `octocatalog-diff` as installed by the gem. diff --git a/script/puppet b/script/puppet index a6d58b6..af4705f 100755 --- a/script/puppet +++ b/script/puppet @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" diff --git a/scripts/env/env.sh b/scripts/env/env.sh index d1169f8..c08b4b6 100644 --- a/scripts/env/env.sh +++ b/scripts/env/env.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script echoes back the environment. This is used for spec testing # and possible debugging. diff --git a/scripts/git-extract/git-extract.sh b/scripts/git-extract/git-extract.sh index 7c8255a..cabe54b 100644 --- a/scripts/git-extract/git-extract.sh +++ b/scripts/git-extract/git-extract.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This script is called from lib/octocatalog-diff/catalog-util/git.rb and is used to # archive and extract a certain branch of a git repository into a target directory. diff --git a/scripts/puppet/puppet.sh b/scripts/puppet/puppet.sh index 0a2b6a7..1b829e6 100644 --- a/scripts/puppet/puppet.sh +++ b/scripts/puppet/puppet.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Script to run Puppet. The default implementation here is simply to pass # through the command line arguments (which are likely to be numerous when diff --git a/spec/octocatalog-diff/fixtures/override-scripts/git-extract.sh b/spec/octocatalog-diff/fixtures/override-scripts/git-extract.sh index 380d835..e6d9302 100644 --- a/spec/octocatalog-diff/fixtures/override-scripts/git-extract.sh +++ b/spec/octocatalog-diff/fixtures/override-scripts/git-extract.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # For test purposes only, this script would ordinarily run a git checkout, but here # it's going to generate a directory structure by copying some other fixture. diff --git a/spec/octocatalog-diff/tests/bootstrap_spec.rb b/spec/octocatalog-diff/tests/bootstrap_spec.rb index a5acd06..af88f97 100644 --- a/spec/octocatalog-diff/tests/bootstrap_spec.rb +++ b/spec/octocatalog-diff/tests/bootstrap_spec.rb @@ -71,10 +71,11 @@ describe OctocatalogDiff::Bootstrap do end it 'should execute bootstrap script with PATH matching environment' do - ENV['PATH'] = @d + '/adslfk' + old_path = ENV['PATH'] + ENV['PATH'] = "#{old_path}:#{@d + '/adslfk'}" result = b(path: @d, bootstrap_script: 'script/bootstrap.sh', bootstrap_args: 'PATH') expect(result[:status_code]).to eq(32) - expect(result[:output].strip).to eq(@d + '/adslfk') + expect(result[:output].strip).to eq("#{old_path}:#{@d + '/adslfk'}") end it 'should execute bootstrap script with BASEDIR matching argument' do diff --git a/spec/octocatalog-diff/tests/spec_helper.rb b/spec/octocatalog-diff/tests/spec_helper.rb index 8478979..0108298 100644 --- a/spec/octocatalog-diff/tests/spec_helper.rb +++ b/spec/octocatalog-diff/tests/spec_helper.rb @@ -183,7 +183,7 @@ module OctocatalogDiff temp_repo_dir = Dir.mktmpdir Dir.mkdir(File.join(temp_repo_dir, 'script')) File.open(File.join(temp_repo_dir, 'script', filename), 'w') do |f| - f.write "#!/bin/bash\n" + f.write "#!/usr/bin/env bash\n" f.write "var=\"${@: -1}\"\n" f.write "if [ \"$var\" = \"\" ]; then exit 31; fi\n" f.write "eval answer=\\$$var\n"