Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 13f084e

Browse files
committed
Fix Shellcheck SC2086: Quote to prevent splitting
Double quote to prevent globbing and word splitting. https://github.com/koalaman/shellcheck/wiki/SC2086 Signed-off-by: Dan Callahan <[email protected]>
1 parent 3109613 commit 13f084e

13 files changed

+42
-42
lines changed

.ci/scripts/test_export_data_command.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Test for the export-data admin command against sqlite and postgres
44

55
set -xe
6-
cd "`dirname $0`/../.."
6+
cd "`dirname "$0"`/../.."
77

88
echo "--- Install dependencies"
99

.ci/scripts/test_synapse_port_db.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
set -xe
10-
cd "`dirname $0`/../.."
10+
cd "`dirname "$0"`/../.."
1111

1212
echo "--- Install dependencies"
1313

debian/build_virtualenv

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ esac
9898
--output-file="${PACKAGE_BUILD_DIR}/etc/matrix-synapse/log.yaml"
9999

100100
# add a dependency on the right version of python to substvars.
101-
PYPKG=`basename $SNAKE`
101+
PYPKG=`basename "$SNAKE"`
102102
echo "synapse:pydepends=$PYPKG" >> debian/matrix-synapse-py3.substvars
103103

104104

demo/clean.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ DIR="$( cd "$( dirname "$0" )" && pwd )"
66

77
PID_FILE="$DIR/servers.pid"
88

9-
if [ -f $PID_FILE ]; then
9+
if [ -f "$PID_FILE" ]; then
1010
echo "servers.pid exists!"
1111
exit 1
1212
fi
1313

1414
for port in 8080 8081 8082; do
15-
rm -rf ${DIR:?}/$port
16-
rm -rf $DIR/media_store.$port
15+
rm -rf "${DIR:?}/$port"
16+
rm -rf "$DIR/media_store.$port"
1717
done
1818

19-
rm -rf ${DIR:?}/etc
19+
rm -rf "${DIR:?}/etc"

demo/start.sh

+24-24
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PYTHONPATH=$(readlink -f "$(pwd)")
1212
export PYTHONPATH
1313

1414

15-
echo $PYTHONPATH
15+
echo "$PYTHONPATH"
1616

1717
for port in 8080 8081 8082; do
1818
echo "Starting server on port $port... "
@@ -28,12 +28,12 @@ for port in 8080 8081 8082; do
2828
--config-path "$DIR/etc/$port.config" \
2929
--report-stats no
3030

31-
if ! grep -F "Customisation made by demo/start.sh" -q $DIR/etc/$port.config; then
32-
printf '\n\n# Customisation made by demo/start.sh\n' >> $DIR/etc/$port.config
31+
if ! grep -F "Customisation made by demo/start.sh" -q "$DIR/etc/$port.config"; then
32+
printf '\n\n# Customisation made by demo/start.sh\n' >> "$DIR/etc/$port.config"
3333

34-
echo "public_baseurl: http://localhost:$port/" >> $DIR/etc/$port.config
34+
echo "public_baseurl: http://localhost:$port/" >> "$DIR/etc/$port.config"
3535

36-
echo 'enable_registration: true' >> $DIR/etc/$port.config
36+
echo 'enable_registration: true' >> "$DIR/etc/$port.config"
3737

3838
# Warning, this heredoc depends on the interaction of tabs and spaces. Please don't
3939
# accidentaly bork me with your fancy settings.
@@ -57,26 +57,26 @@ for port in 8080 8081 8082; do
5757
compress: false
5858
PORTLISTENERS
5959
)
60-
echo "${listeners}" >> $DIR/etc/$port.config
60+
echo "${listeners}" >> "$DIR/etc/$port.config"
6161

6262
# Disable tls for the servers
63-
printf '\n\n# Disable tls on the servers.' >> $DIR/etc/$port.config
64-
echo '# DO NOT USE IN PRODUCTION' >> $DIR/etc/$port.config
65-
echo 'use_insecure_ssl_client_just_for_testing_do_not_use: true' >> $DIR/etc/$port.config
66-
echo 'federation_verify_certificates: false' >> $DIR/etc/$port.config
63+
printf '\n\n# Disable tls on the servers.' >> "$DIR/etc/$port.config"
64+
echo '# DO NOT USE IN PRODUCTION' >> "$DIR/etc/$port.config"
65+
echo 'use_insecure_ssl_client_just_for_testing_do_not_use: true' >> "$DIR/etc/$port.config"
66+
echo 'federation_verify_certificates: false' >> "$DIR/etc/$port.config"
6767

6868
# Set tls paths
69-
echo "tls_certificate_path: \"$DIR/etc/localhost:$https_port.tls.crt\"" >> $DIR/etc/$port.config
70-
echo "tls_private_key_path: \"$DIR/etc/localhost:$https_port.tls.key\"" >> $DIR/etc/$port.config
69+
echo "tls_certificate_path: \"$DIR/etc/localhost:$https_port.tls.crt\"" >> "$DIR/etc/$port.config"
70+
echo "tls_private_key_path: \"$DIR/etc/localhost:$https_port.tls.key\"" >> "$DIR/etc/$port.config"
7171

7272
# Generate tls keys
73-
openssl req -x509 -newkey rsa:4096 -keyout $DIR/etc/localhost:$https_port.tls.key -out $DIR/etc/localhost:$https_port.tls.crt -days 365 -nodes -subj "/O=matrix"
73+
openssl req -x509 -newkey rsa:4096 -keyout "$DIR/etc/localhost:$https_port.tls.key" -out "$DIR/etc/localhost:$https_port.tls.crt" -days 365 -nodes -subj "/O=matrix"
7474

7575
# Ignore keys from the trusted keys server
76-
echo '# Ignore keys from the trusted keys server' >> $DIR/etc/$port.config
77-
echo 'trusted_key_servers:' >> $DIR/etc/$port.config
78-
echo ' - server_name: "matrix.org"' >> $DIR/etc/$port.config
79-
echo ' accept_keys_insecurely: true' >> $DIR/etc/$port.config
76+
echo '# Ignore keys from the trusted keys server' >> "$DIR/etc/$port.config"
77+
echo 'trusted_key_servers:' >> "$DIR/etc/$port.config"
78+
echo ' - server_name: "matrix.org"' >> "$DIR/etc/$port.config"
79+
echo ' accept_keys_insecurely: true' >> "$DIR/etc/$port.config"
8080

8181
# Reduce the blacklist
8282
blacklist=$(cat <<-BLACK
@@ -91,12 +91,12 @@ for port in 8080 8081 8082; do
9191
- 'fc00::/7'
9292
BLACK
9393
)
94-
echo "${blacklist}" >> $DIR/etc/$port.config
94+
echo "${blacklist}" >> "$DIR/etc/$port.config"
9595
fi
9696

9797
# Check script parameters
9898
if [ $# -eq 1 ]; then
99-
if [ $1 = "--no-rate-limit" ]; then
99+
if [ "$1" = "--no-rate-limit" ]; then
100100

101101
# Disable any rate limiting
102102
ratelimiting=$(cat <<-RC
@@ -138,15 +138,15 @@ for port in 8080 8081 8082; do
138138
burst_count: 1000
139139
RC
140140
)
141-
echo "${ratelimiting}" >> $DIR/etc/$port.config
141+
echo "${ratelimiting}" >> "$DIR/etc/$port.config"
142142
fi
143143
fi
144144

145-
if ! grep -F "full_twisted_stacktraces" -q $DIR/etc/$port.config; then
146-
echo "full_twisted_stacktraces: true" >> $DIR/etc/$port.config
145+
if ! grep -F "full_twisted_stacktraces" -q "$DIR/etc/$port.config"; then
146+
echo "full_twisted_stacktraces: true" >> "$DIR/etc/$port.config"
147147
fi
148-
if ! grep -F "report_stats" -q $DIR/etc/$port.config ; then
149-
echo "report_stats: false" >> $DIR/etc/$port.config
148+
if ! grep -F "report_stats" -q "$DIR/etc/$port.config" ; then
149+
echo "report_stats: false" >> "$DIR/etc/$port.config"
150150
fi
151151

152152
python3 -m synapse.app.homeserver \

demo/stop.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ for pid_file in $FILES; do
88
pid=$(cat "$pid_file")
99
if [[ $pid ]]; then
1010
echo "Killing $pid_file with $pid"
11-
kill $pid
11+
kill "$pid"
1212
fi
1313
done
1414

docker/build_debian.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
set -ex
66

77
# Get the codename from distro env
8-
DIST=`cut -d ':' -f2 <<< ${distro:?}`
8+
DIST=`cut -d ':' -f2 <<< "${distro:?}"`
99

1010
# we get a read-only copy of the source: make a writeable copy
1111
cp -aT /synapse/source /synapse/build

scripts-dev/check-newsfragment

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ echo
4444
matched=0
4545
for f in `git diff --name-only FETCH_HEAD... -- changelog.d`; do
4646
# check that any modified newsfiles on this branch end with a full stop.
47-
lastchar=`tr -d '\n' < $f | tail -c 1`
48-
if [ $lastchar != '.' ] && [ $lastchar != '!' ]; then
47+
lastchar=`tr -d '\n' < "$f" | tail -c 1`
48+
if [ "$lastchar" != '.' ] && [ "$lastchar" != '!' ]; then
4949
echo -e "\e[31mERROR: newsfragment $f does not end with a '.' or '!'\e[39m" >&2
5050
echo -e "$CONTRIBUTING_GUIDE_TEXT" >&2
5151
exit 1

scripts-dev/check_line_terminators.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# terminators are found, 0 otherwise.
2626

2727
# cd to the root of the repository
28-
cd "`dirname $0`/.." || exit
28+
cd "`dirname "$0"`/.." || exit
2929

3030
# Find and print files with non-unix line terminators
3131
if find . -path './.git/*' -prune -o -type f -print0 | xargs -0 grep -I -l $'\r$'; then

scripts-dev/complement.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
set -e
2525

2626
# Change to the repository root
27-
cd "$(dirname $0)/.."
27+
cd "$(dirname "$0")/.."
2828

2929
# Check for a user-specified Complement checkout
3030
if [[ -z "$COMPLEMENT_DIR" ]]; then
@@ -61,8 +61,8 @@ cd "$COMPLEMENT_DIR"
6161
EXTRA_COMPLEMENT_ARGS=""
6262
if [[ -n "$1" ]]; then
6363
# A test name regex has been set, supply it to Complement
64-
EXTRA_COMPLEMENT_ARGS+="-run $1 "
64+
EXTRA_COMPLEMENT_ARGS=(-run "$1")
6565
fi
6666

6767
# Run the tests!
68-
go test -v -tags synapse_blacklist,msc2946,msc3083,msc2403,msc2716 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests/...
68+
go test -v -tags synapse_blacklist,msc2946,msc3083,msc2403,msc2716 -count=1 "${EXTRA_COMPLEMENT_ARGS[@]}" ./tests/...

scripts-dev/config-lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Exits with 0 if there are no problems, or another code otherwise.
44

55
# cd to the root of the repository
6-
cd "`dirname $0`/.." || exit
6+
cd "`dirname "$0"`/.." || exit
77

88
# Restore backup of sample config upon script exit
99
trap "mv docs/sample_config.yaml.bak docs/sample_config.yaml" EXIT

scripts-dev/docker_update_debian_changelog.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y devscripts
6060

6161
# Update the Debian changelog.
6262
ver=${1}
63-
dch -M -v "$(sed -Ee 's/(rc|a|b|c)/~\1/' <<<$ver)" "New synapse release $ver."
63+
dch -M -v "$(sed -Ee 's/(rc|a|b|c)/~\1/' <<<"$ver")" "New synapse release $ver."
6464
dch -M -r -D stable ""

scripts-dev/generate_sample_config

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
set -e
66

7-
cd "`dirname $0`/.."
7+
cd "`dirname "$0"`/.."
88

99
SAMPLE_CONFIG="docs/sample_config.yaml"
1010
SAMPLE_LOG_CONFIG="docs/sample_log_config.yaml"

0 commit comments

Comments
 (0)