Skip to content

Commit

Permalink
/bin/(ba|c)?sh -> /usr/bin/env $1sh
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie committed Aug 12, 2021
1 parent 66fc694 commit 8687597
Show file tree
Hide file tree
Showing 30 changed files with 47 additions and 42 deletions.
2 changes: 1 addition & 1 deletion bin/sbang
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# sbang project developers. See the top-level COPYRIGHT file for details.
Expand Down
2 changes: 1 addition & 1 deletion bin/spack
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
# -*- python -*-
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
Expand Down
2 changes: 1 addition & 1 deletion bin/spack-python
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand Down
6 changes: 3 additions & 3 deletions lib/spack/docs/workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ again in the future. For example:

.. code-block:: sh
#!/bin/sh
#!/usr/bin/env sh
spack install modele-utils
spack install emacs
spack install ncview
Expand Down Expand Up @@ -175,7 +175,7 @@ of usage:

.. code-block:: sh
#!/bin/bash
#!/usr/bin/env bash
compilers=(
%gcc
Expand Down Expand Up @@ -308,7 +308,7 @@ example:

.. code-block:: sh
#!/bin/sh
#!/usr/bin/env sh
#
# Generate module load commands in ~/env/spackenv
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/env/cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/cmd/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def ci_rebuild(args):

# Write the install command to a shell script
with open('install.sh', 'w') as fd:
fd.write('#!/bin/bash\n\n')
fd.write('#!/usr/bin/env bash\n\n')
fd.write('\n# spack install command\n')
fd.write(' '.join(['"{0}"'.format(i) for i in install_args]))
fd.write('\n')
Expand Down
10 changes: 5 additions & 5 deletions lib/spack/spack/test/cmd/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def mock_compiler_dir(tmpdir, mock_compiler_version):
gfortran_path = bin_dir.join('gfortran')

gcc_path.write("""\
#!/bin/sh
#!/usr/bin/env sh
for arg in "$@"; do
if [ "$arg" = -dumpversion ]; then
Expand All @@ -67,7 +67,7 @@ def test_compiler_find_without_paths(no_compilers_yaml, working_env, tmpdir):
with tmpdir.as_cwd():
with open('gcc', 'w') as f:
f.write("""\
#!/bin/sh
#!/usr/bin/env sh
echo "0.0.0"
""")
os.chmod('gcc', 0o700)
Expand All @@ -84,7 +84,7 @@ def test_compiler_find_no_apple_gcc(no_compilers_yaml, working_env, tmpdir):
# make a script to emulate apple gcc's version args
with open('gcc', 'w') as f:
f.write("""\
#!/bin/sh
#!/usr/bin/env sh
if [ "$1" = "-dumpversion" ]; then
echo "4.2.1"
elif [ "$1" = "--version" ]; then
Expand Down Expand Up @@ -150,7 +150,7 @@ def clangdir(tmpdir):
with tmpdir.as_cwd():
with open('clang', 'w') as f:
f.write("""\
#!/bin/sh
#!/usr/bin/env sh
if [ "$1" = "--version" ]; then
echo "clang version 11.0.0 (clang-1100.0.33.16)"
echo "Target: x86_64-apple-darwin18.7.0"
Expand All @@ -164,7 +164,7 @@ def clangdir(tmpdir):
shutil.copy('clang', 'clang++')

gcc_script = """\
#!/bin/sh
#!/usr/bin/env sh
if [ "$1" = "-dumpversion" ]; then
echo "8"
elif [ "$1" = "-dumpfullversion" ]; then
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/cmd/gpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
('gpg2', 'gpg (GnuPG) 2.2.19'), # gpg2 command
])
def test_find_gpg(cmd_name, version, tmpdir, mock_gnupghome, monkeypatch):
TEMPLATE = ('#!/bin/sh\n'
TEMPLATE = ('#!/usr/bin/env sh\n'
'echo "{version}"\n')

with tmpdir.as_cwd():
Expand Down
8 changes: 4 additions & 4 deletions lib/spack/spack/test/compilers/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def test_get_compiler_link_paths_no_verbose_flag():
def test_get_compiler_link_paths_load_env(working_env, monkeypatch, tmpdir):
gcc = str(tmpdir.join('gcc'))
with open(gcc, 'w') as f:
f.write("""#!/bin/bash
f.write("""#!/usr/bin/env bash
if [[ $ENV_SET == "1" && $MODULE_LOADED == "1" ]]; then
echo '""" + no_flag_output + """'
fi
Expand Down Expand Up @@ -704,7 +704,7 @@ def test_compiler_get_real_version(working_env, monkeypatch, tmpdir):
# Create compiler
gcc = str(tmpdir.join('gcc'))
with open(gcc, 'w') as f:
f.write("""#!/bin/bash
f.write("""#!/usr/bin/env bash
if [[ $CMP_ON == "1" ]]; then
echo "$CMP_VER"
fi
Expand Down Expand Up @@ -754,7 +754,7 @@ def test_compiler_get_real_version_fails(working_env, monkeypatch, tmpdir):
# Create compiler
gcc = str(tmpdir.join('gcc'))
with open(gcc, 'w') as f:
f.write("""#!/bin/bash
f.write("""#!/usr/bin/env bash
if [[ $CMP_ON == "1" ]]; then
echo "$CMP_VER"
fi
Expand Down Expand Up @@ -810,7 +810,7 @@ def test_compiler_flags_use_real_version(working_env, monkeypatch, tmpdir):
# Create compiler
gcc = str(tmpdir.join('gcc'))
with open(gcc, 'w') as f:
f.write("""#!/bin/bash
f.write("""#!/usr/bin/env bash
echo "4.4.4"
""") # Version for which c++11 flag is -std=c++0x
fs.set_executable(gcc)
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ def mock_archive(request, tmpdir_factory):
'configure'))
with open(configure_path, 'w') as f:
f.write(
"#!/bin/sh\n"
"#!/usr/bin/env sh\n"
"prefix=$(echo $1 | sed 's/--prefix=//')\n"
"cat > Makefile <<EOF\n"
"all:\n"
Expand Down
6 changes: 3 additions & 3 deletions lib/spack/spack/test/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def test_get_version_no_match_git(tmpdir, working_env):
git = str(tmpdir.join("git"))
with open(git, "w") as f:
f.write("""#!/bin/sh
f.write("""#!/usr/bin/env sh
echo v0.13.3
""")
fs.set_executable(git)
Expand All @@ -26,7 +26,7 @@ def test_get_version_no_match_git(tmpdir, working_env):
def test_get_version_match_git(tmpdir, working_env):
git = str(tmpdir.join("git"))
with open(git, "w") as f:
f.write("""#!/bin/sh
f.write("""#!/usr/bin/env sh
echo v0.13.3-912-g3519a1762
""")
fs.set_executable(git)
Expand Down Expand Up @@ -54,7 +54,7 @@ def test_main_calls_get_version(tmpdir, capsys, working_env):
def test_get_version_bad_git(tmpdir, working_env):
bad_git = str(tmpdir.join("git"))
with open(bad_git, "w") as f:
f.write("""#!/bin/sh
f.write("""#!/usr/bin/env sh
exit 1
""")
fs.set_executable(bad_git)
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/make_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def setUp(self):

make_exe = os.path.join(self.tmpdir, 'make')
with open(make_exe, 'w') as f:
f.write('#!/bin/sh\n')
f.write('#!/usr/bin/env sh\n')
f.write('echo "$@"')
os.chmod(make_exe, 0o700)

Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_buildcache(mock_archive, tmpdir):
mkdirp(os.path.join(pkg.prefix, "bin"))
patchelfscr = os.path.join(pkg.prefix, "bin", "patchelf")
f = open(patchelfscr, 'w')
body = """#!/bin/bash
body = """#!/usr/bin/env bash
echo $PATH"""
f.write(body)
f.close()
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
_hidden_fn = '.hidden'
_readme_fn = 'README.txt'

_extra_contents = '#!/bin/sh\n'
_extra_contents = '#!/usr/bin/env sh\n'
_hidden_contents = ''
_readme_contents = 'hello world!\n'

Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/url_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_fetch(

with open('configure') as f:
contents = f.read()
assert contents.startswith('#!/bin/sh')
assert contents.startswith('#!/usr/bin/env sh')
assert 'echo Building...' in contents


Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/util/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _make_exe(tmpdir_factory, name, contents=None):
path = str(tmpdir_factory.mktemp('%s_exe' % name).join(name))
if contents is not None:
with open(path, 'w') as f:
f.write('#!/bin/sh\n%s\n' % contents)
f.write('#!/usr/bin/env sh\n%s\n' % contents)
set_executable(path)
return path

Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/util/log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_log_parser(tmpdir):
log_file = tmpdir.join('log.txt')

with log_file.open('w') as f:
f.write("""#!/bin/sh\n
f.write("""#!/usr/bin/env sh\n
checking build system type... x86_64-apple-darwin16.6.0
checking host system type... x86_64-apple-darwin16.6.0
error: weird_error.c:145: something weird happened E
Expand Down
2 changes: 1 addition & 1 deletion share/spack/qa/bashcov
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# This script acts like bash but runs kcov on the input script. We use it
# to get coverage for Spack's bash scripts.
Expand Down
2 changes: 1 addition & 1 deletion share/spack/qa/completion-test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand Down
3 changes: 2 additions & 1 deletion share/spack/qa/run-build-tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env bash
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand All @@ -14,6 +14,7 @@
# Usage:
# run-build-tests
#
set -e
. "$(dirname $0)/setup.sh"
check_dependencies ${coverage} git hg svn

Expand Down
3 changes: 2 additions & 1 deletion share/spack/qa/run-doc-tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env bash
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand All @@ -14,6 +14,7 @@
# Usage:
# run-doc-tests
#
set -e
. "$(dirname $0)/setup.sh"
check_dependencies sphinx-apidoc sphinx-build dot git hg svn

Expand Down
3 changes: 2 additions & 1 deletion share/spack/qa/run-shell-tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env bash
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand All @@ -15,6 +15,7 @@
#-----------------------------------------------------------
# Run a few initial commands and set up test environment
#-----------------------------------------------------------
set -e
ORIGINAL_PATH="$PATH"

. "$(dirname $0)/setup.sh"
Expand Down
3 changes: 2 additions & 1 deletion share/spack/qa/run-style-tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env bash
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand All @@ -14,6 +14,7 @@
# Usage:
# run-flake8-tests
#
set -e
. "$(dirname $0)/setup.sh"

BASE=""
Expand Down
3 changes: 2 additions & 1 deletion share/spack/qa/run-unit-tests
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env bash
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand All @@ -20,6 +20,7 @@
#-----------------------------------------------------------
# Run a few initial commands and set up test environment
#-----------------------------------------------------------
set -e
ORIGINAL_PATH="$PATH"

. "$(dirname $0)/setup.sh"
Expand Down
2 changes: 1 addition & 1 deletion share/spack/qa/setup-env-test.csh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/csh
#!/usr/bin/env csh
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand Down
2 changes: 1 addition & 1 deletion share/spack/qa/setup-env-test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand Down
4 changes: 2 additions & 2 deletions share/spack/qa/setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/usr/bin/env bash
#
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
Expand All @@ -9,7 +9,7 @@
# Description:
# Common setup code to be sourced by Spack's test scripts.
#

set -e
QA_DIR="$(dirname ${BASH_SOURCE[0]})"
export SPACK_ROOT=$(realpath "$QA_DIR/../../..")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BuildError(Package):

def install(self, spec, prefix):
with open('configure', 'w') as f:
f.write("""#!/bin/sh\n
f.write("""#!/usr/bin/env sh\n
echo 'checking build system type... x86_64-apple-darwin16.6.0'
echo 'checking host system type... x86_64-apple-darwin16.6.0'
echo 'checking for gcc... /Users/gamblin2/src/spack/lib/spack/env/clang/clang'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BuildWarnings(Package):

def install(self, spec, prefix):
with open('configure', 'w') as f:
f.write("""#!/bin/sh\n
f.write("""#!/usr/bin/env sh\n
echo 'checking for gcc... /Users/gamblin2/src/spack/lib/spack/env/clang/clang'
echo 'checking whether the C compiler works... yes'
echo 'checking for C compiler default output file name... a.out'
Expand Down
2 changes: 1 addition & 1 deletion var/spack/repos/builtin.mock/packages/gcc/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def install(self, spec, prefix):
# Create the minimal compiler that will fool `spack compiler find`
mkdirp(prefix.bin)
with open(prefix.bin.gcc, 'w') as f:
f.write('#!/bin/bash\necho "%s"' % str(spec.version))
f.write('#!/usr/bin/env bash\necho "%s"' % str(spec.version))
set_executable(prefix.bin.gcc)

0 comments on commit 8687597

Please sign in to comment.