Skip to content

Commit 51ec25c

Browse files
authored
Resolve shellcheck errors/warnings (#1164)
Issue: #1162
1 parent 0ca8dcf commit 51ec25c

File tree

5 files changed

+16
-136
lines changed

5 files changed

+16
-136
lines changed

assets/test/sleep.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
sleep $1
2-
exit $2
1+
#!/bin/bash
2+
sleep "$1"
3+
exit "$2"

docker/test-ci.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#!/usr/bin/env node
1+
#!/bin/bash
22

3+
node << 'EOF'
34
const { execSync } = require('child_process');
45
56
// Default to 'ci' if no argument is provided
@@ -9,7 +10,8 @@ const job = (process.argv[2] || 'ci')
910
const swiftVersion = (process.argv[3] || 'main').replace(/\./g, '');
1011
1112
const baseConfigFile = job === 'ci' ? 'docker-compose.yaml' : 'docker-compose-nightly.yaml'
12-
const command = `docker compose -f docker/${baseConfigFile} -f docker/docker-compose.*.${swiftVersion}.yaml -p swift-vscode-${swiftVersion}-prb run --rm test`;
13+
const command = `docker compose -f docker/${baseConfigFile} -f docker/docker-compose.*.${swiftVersion}.yaml -p swift-vscode-${swiftVersion}-prb run --rm -T test`;
1314
1415
console.log(`Running: ${command}`);
15-
execSync(command, { stdio: 'inherit' });
16+
execSync(command, { stdio: 'inherit' });
17+
EOF

docker/test.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
set -ex
23

34
current_directory=$(pwd)
@@ -18,5 +19,5 @@ npm run lint
1819
npm run format
1920
npm run package
2021

21-
(xvfb-run -a npm run coverage; echo $? > exitcode) | grep -Ev "Failed to connect to the bus|GPU stall due to ReadPixels" && rm -rf "${current_directory}/coverage" && (cp -R ./coverage $current_directory || true)
22-
exit $(<exitcode)
22+
(xvfb-run -a npm run coverage; echo $? > exitcode) | grep -Ev "Failed to connect to the bus|GPU stall due to ReadPixels" && rm -rf "${current_directory}/coverage" && (cp -R ./coverage "${current_directory}" || true)
23+
exit "$(<exitcode)"

scripts/soundness.sh

Lines changed: 4 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,6 @@
11
#!/bin/bash
2-
##===----------------------------------------------------------------------===##
3-
##
4-
## This source file is part of the VS Code Swift open source project
5-
##
6-
## Copyright (c) 2021 the VS Code Swift project authors
7-
## Licensed under Apache License v2.0
8-
##
9-
## See LICENSE.txt for license information
10-
## See CONTRIBUTORS.txt for the list of VS Code Swift project authors
11-
##
12-
## SPDX-License-Identifier: Apache-2.0
13-
##
14-
##===----------------------------------------------------------------------===##
152

16-
set -eu
17-
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
18-
19-
function replace_acceptable_years() {
20-
# this needs to replace all acceptable forms with 'YEARS'
21-
sed -e 's/20[12][0123456789]-20[12][0123456789]/YEARS/' -e 's/20[12][0123456789]/YEARS/'
22-
}
23-
24-
printf "=> Checking for unacceptable language... "
25-
# This greps for unacceptable terminology. The square bracket[s] are so that
26-
# "git grep" doesn't find the lines that greps :).
27-
unacceptable_terms=(
28-
-e blacklis[t]
29-
-e whitelis[t]
30-
-e slav[e]
31-
-e sanit[y]
32-
)
33-
34-
# We have to exclude the code of conduct as it gives examples of unacceptable
35-
# language.
36-
if git grep --color=never -i "${unacceptable_terms[@]}" -- . ":(exclude)CODE_OF_CONDUCT.md" > /dev/null; then
37-
printf "\033[0;31mUnacceptable language found.\033[0m\n"
38-
git grep -i "${unacceptable_terms[@]}" -- . ":(exclude)CODE_OF_CONDUCT.md"
39-
exit 1
40-
fi
41-
printf "\033[0;32mokay.\033[0m\n"
42-
43-
printf "=> Checking license headers... "
44-
tmp=$(mktemp /tmp/.vscode-swift-soundness_XXXXXX)
45-
46-
for language in typescript-or-javascript bash; do
47-
declare -a matching_files
48-
matching_files=( -name '*' )
49-
case "$language" in
50-
typescript-or-javascript)
51-
matching_files=( -name '*.js' -o -name '*.ts' )
52-
cat > "$tmp" <<"EOF"
53-
//===----------------------------------------------------------------------===//
54-
//
55-
// This source file is part of the VS Code Swift open source project
56-
//
57-
// Copyright (c) YEARS the VS Code Swift project authors
58-
// Licensed under Apache License v2.0
59-
//
60-
// See LICENSE.txt for license information
61-
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
62-
//
63-
// SPDX-License-Identifier: Apache-2.0
64-
//
65-
//===----------------------------------------------------------------------===//
66-
EOF
67-
;;
68-
bash)
69-
matching_files=( -name '*.sh' )
70-
cat > "$tmp" <<"EOF"
71-
#!/bin/bash
72-
##===----------------------------------------------------------------------===##
73-
##
74-
## This source file is part of the VS Code Swift open source project
75-
##
76-
## Copyright (c) YEARS the VS Code Swift project authors
77-
## Licensed under Apache License v2.0
78-
##
79-
## See LICENSE.txt for license information
80-
## See CONTRIBUTORS.txt for the list of VS Code Swift project authors
81-
##
82-
## SPDX-License-Identifier: Apache-2.0
83-
##
84-
##===----------------------------------------------------------------------===##
85-
EOF
86-
;;
87-
*)
88-
echo >&2 "ERROR: unknown language '$language'"
89-
;;
90-
esac
91-
92-
expected_lines=$(cat "$tmp" | wc -l)
93-
expected_sha=$(cat "$tmp" | shasum)
94-
95-
(
96-
cd "$here/.."
97-
{
98-
find . \
99-
\( \! -path './.build/*' -a \
100-
\( \! -path './node_modules/*' -a \
101-
\( \! -path './out/*' -a \
102-
\( \! -path './.vscode-test/*' -a \
103-
\( \! -path './docker/*' -a \
104-
\( \! -path './dist/*' -a \
105-
\( \! -path './assets/*' -a \
106-
\( \! -path './coverage/*' -a \
107-
\( "${matching_files[@]}" \) \
108-
\) \) \) \) \) \) \) \)
109-
110-
if [[ "$language" = bash ]]; then
111-
# add everything with a shell shebang too
112-
git grep --full-name -l '#!/bin/bash'
113-
git grep --full-name -l '#!/bin/sh'
114-
fi
115-
} | while read line; do
116-
if [[ "$(cat "$line" | replace_acceptable_years | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then
117-
printf "\033[0;31mmissing headers in file '$line'!\033[0m\n"
118-
diff -u <(cat "$line" | replace_acceptable_years | head -n $expected_lines) "$tmp"
119-
exit 1
120-
fi
121-
done
122-
printf "\033[0;32mokay.\033[0m\n"
123-
)
124-
done
125-
126-
rm "$tmp"
127-
128-
printf "=> Checking for broken links in documentation... "
129-
find . -name node_modules -prune -o -name \*.md -print0 | xargs -0 -n1 npx markdown-link-check
130-
printf "\033[0;32mokay.\033[0m\n"
3+
# This file is supplanted by the GitHub Actions enabled in
4+
# https://github.com/swiftlang/vscode-swift/pull/1159,
5+
# remove this file once that has been merged.
6+
exit 0

scripts/tag_release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tag=$1
1717

1818
if [[ -z $tag ]]; then
1919
echo "tag_release.sh requires a tag"
20-
exit -1
20+
exit 1
2121
fi
2222

2323
echo "Tagging v$tag"

0 commit comments

Comments
 (0)