Use #!/usr/bin/env for bash shebangs.

/bin/sh and /usr/bin/env are the only two binaries that NixOS provides
at a fixed path (outside a buildFHSUserEnv sandbox).

This discussion was split from #11004.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2018-12-17 17:08:53 -08:00
parent 66c02e4dc7
commit 392175d6e8
44 changed files with 52 additions and 47 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -eu set -eu
#"OK": 0 #"OK": 0

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
#"OK": 0 #"OK": 0
#"WARNING": 1 #"WARNING": 1

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Checks for any Zulip queue workers that are leaking memory and thus have a high vsize # Checks for any Zulip queue workers that are leaking memory and thus have a high vsize
datafile=$(mktemp) datafile=$(mktemp)

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -x set -x
set -e set -e

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -x set -x
set -e set -e

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
zulip_conf_get_boolean() { zulip_conf_get_boolean() {
# Get a boolean flag from zulip.conf, using the Python # Get a boolean flag from zulip.conf, using the Python

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
release=$(lsb_release -sc) release=$(lsb_release -sc)
if [ "$release" = "xenial" ] && [ -x /sbin/start ] && [ -x /sbin/stop ] && [ -x /sbin/restart ] && [ -x /sbin/status ] && [ -x /sbin/initctl ]; then if [ "$release" = "xenial" ] && [ -x /sbin/start ] && [ -x /sbin/stop ] && [ -x /sbin/restart ] && [ -x /sbin/status ] && [ -x /sbin/initctl ]; then

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
if { [ "$ZULIP_USER_CREATION_ENABLED" == "True" ] || [ "$ZULIP_USER_CREATION_ENABLED" == "true" ]; } && \ if { [ "$ZULIP_USER_CREATION_ENABLED" == "True" ] || [ "$ZULIP_USER_CREATION_ENABLED" == "true" ]; } && \
{ [ -z "$ZULIP_USER_DOMAIN" ] || \ { [ -z "$ZULIP_USER_DOMAIN" ] || \

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -eu set -eu
version=0.6.0 version=0.6.0

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -x set -x
set -e set -e

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -x set -x
set -e set -e

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -x set -x
set -e set -e

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# #
# Thin wrapper around the actual install script (scripts/lib/install). # Thin wrapper around the actual install script (scripts/lib/install).
# The purpose of this wrapper is to log the full install script output # The purpose of this wrapper is to log the full install script output

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
set -x set -x

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then

View File

@ -1,2 +1,2 @@
#!/bin/bash #!/usr/bin/env bash
"$(dirname "$0")/lib/upgrade-zulip" "$@" 2>&1 | tee -a /var/log/zulip/upgrade.log "$(dirname "$0")/lib/upgrade-zulip" "$@" 2>&1 | tee -a /var/log/zulip/upgrade.log

View File

@ -1,2 +1,2 @@
#!/bin/bash #!/usr/bin/env bash
"$(dirname "$0")/lib/upgrade-zulip-from-git" "$@" 2>&1 | tee -a /var/log/zulip/upgrade.log "$(dirname "$0")/lib/upgrade-zulip-from-git" "$@" 2>&1 | tee -a /var/log/zulip/upgrade.log

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
source /srv/zulip-py3-venv/bin/activate source /srv/zulip-py3-venv/bin/activate
echo "Using $VIRTUAL_ENV" echo "Using $VIRTUAL_ENV"

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
source tools/ci/activate-venv source tools/ci/activate-venv
echo "Test suite is running under $(python --version)." echo "Test suite is running under $(python --version)."

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
source tools/ci/activate-venv source tools/ci/activate-venv

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
set -x set -x

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# This test installs a Zulip production environment (from the release # This test installs a Zulip production environment (from the release
# tarball from setup-production), and then runs some Nagios checks and # tarball from setup-production), and then runs some Nagios checks and
# other tools to verify that everything is working properly. # other tools to verify that everything is working properly.

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
set -x set -x

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# In short, this provisions a Zulip development environment and then # In short, this provisions a Zulip development environment and then
# builds a Zulip release tarball (the same way we build them for an # builds a Zulip release tarball (the same way we build them for an
# actual release). The actual test job will then install that. # actual release). The actual test job will then install that.

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Lint all commit messages that are newer than upstream/master if running # Lint all commit messages that are newer than upstream/master if running
# locally or the commits in the push or PR if in Travis CI. # locally or the commits in the push or PR if in Travis CI.

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# This hook runs gitlint on your commit message. # This hook runs gitlint on your commit message.

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
function error_out { function error_out {
echo -en '\e[0;31m' echo -en '\e[0;31m'

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
set -x set -x

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
set -x set -x

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Hackish tool for attempting to find unused IDs / classes in our CSS # Hackish tool for attempting to find unused IDs / classes in our CSS
for n in $(perl -lne 'print $1 while /[#.]([a-zA-Z0-9_-]+)/g' static/styles/zulip.css | sort -u); do for n in $(perl -lne 'print $1 while /[#.]([a-zA-Z0-9_-]+)/g' static/styles/zulip.css | sort -u); do

View File

@ -179,10 +179,15 @@ def custom_check_file(fn: str,
shebang_rules = [{'pattern': '^#!', shebang_rules = [{'pattern': '^#!',
'description': "zerver library code shouldn't have a shebang line."}] 'description': "zerver library code shouldn't have a shebang line."}]
else: else:
shebang_rules = [{'pattern': '#!/usr/bin/python', shebang_rules = [
'description': "Use `#!/usr/bin/env python3` instead of `#!/usr/bin/python`"}, # /bin/sh and /usr/bin/env are the only two binaries
{'pattern': '#!/usr/bin/env python$', # that NixOS provides at a fixed path (outside a
'description': "Use `#!/usr/bin/env python3` instead of `#!/usr/bin/env python`."}] # buildFHSUserEnv sandbox).
{'pattern': '^#!(?! *(?:/usr/bin/env|/bin/sh)(?: |$))',
'description': "Use `#!/usr/bin/env foo` instead of `#!/path/foo` for interpreters other than sh."},
{'pattern': '^#!/usr/bin/env python$',
'description': "Use `#!/usr/bin/env python3` instead of `#!/usr/bin/env python`."}
]
for rule in shebang_rules: for rule in shebang_rules:
if re.search(rule['pattern'], firstline): if re.search(rule['pattern'], firstline):
print_err(identifier, color, print_err(identifier, color,

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# This hook runs the Zulip code linter ./tools/lint and returns true # This hook runs the Zulip code linter ./tools/lint and returns true
# regardless of linter results so that your commit may continue. # regardless of linter results so that your commit may continue.

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Use this script to provision dependencies for your Zulip installation. # Use this script to provision dependencies for your Zulip installation.
# This script is idempotent, so it can be restarted at any time, and it # This script is idempotent, so it can be restarted at any time, and it

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
usage () { usage () {

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
if ! git diff-index --quiet HEAD; then if ! git diff-index --quiet HEAD; then

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
if ! [ -d ".git/hooks/" ]; then if ! [ -d ".git/hooks/" ]; then
echo "Error: Could not find .git/hooks directory" echo "Error: Could not find .git/hooks directory"

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
if [ "$(node_modules/.bin/svgo -f static/images/integrations/logos | grep -o '\.[0-9]% = ' | wc -l)" -ge 1 ] if [ "$(node_modules/.bin/svgo -f static/images/integrations/logos | grep -o '\.[0-9]% = ' | wc -l)" -ge 1 ]
then then

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
sudo service rabbitmq-server restart sudo service rabbitmq-server restart
sudo service postgresql restart sudo service postgresql restart

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
sudo service rabbitmq-server restart sudo service rabbitmq-server restart
sudo service postgresql restart sudo service postgresql restart

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
usage() { usage() {

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
usage() { usage() {

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
usage() { usage() {

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
echo 'Testing whether migrations are consistent with models' echo 'Testing whether migrations are consistent with models'