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
#"OK": 0

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#"OK": 0
#"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
datafile=$(mktemp)

View File

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

View File

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

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
zulip_conf_get_boolean() {
# 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)
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" ]; } && \
{ [ -z "$ZULIP_USER_DOMAIN" ] || \

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Thin wrapper around the actual install script (scripts/lib/install).
# 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 -x

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
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

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

View File

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

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
source tools/ci/activate-venv
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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# In short, this provisions a Zulip development environment and then
# builds a Zulip release tarball (the same way we build them for an
# 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
# 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.

View File

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

View File

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

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
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
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': '^#!',
'description': "zerver library code shouldn't have a shebang line."}]
else:
shebang_rules = [{'pattern': '#!/usr/bin/python',
'description': "Use `#!/usr/bin/env python3` instead of `#!/usr/bin/python`"},
{'pattern': '#!/usr/bin/env python$',
'description': "Use `#!/usr/bin/env python3` instead of `#!/usr/bin/env python`."}]
shebang_rules = [
# /bin/sh and /usr/bin/env are the only two binaries
# that NixOS provides at a fixed path (outside a
# 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:
if re.search(rule['pattern'], firstline):
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
# 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.
# 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
usage () {

View File

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

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
if ! [ -d ".git/hooks/" ]; then
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 ]
then

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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