Skip to content

Commit 7ccdbd5

Browse files
committed
Use consistent syntax for Bash function declarations
1 parent bc2402e commit 7ccdbd5

17 files changed

+57
-45
lines changed

scripts/check_style.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ then
3535
exit 1
3636
fi
3737

38-
function preparedGrep()
38+
function preparedGrep
3939
{
4040
git grep -nIE "$1" -- '*.h' '*.cpp' | grep -v "${EXCLUDE_FILES_JOINED}"
4141
return $?

scripts/ci/build_ossfuzz.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ROOTDIR="/root/project"
55
BUILDDIR="${ROOTDIR}/build"
66
mkdir -p "${BUILDDIR}" && mkdir -p "$BUILDDIR/deps"
77

8-
generate_protobuf_bindings()
8+
function generate_protobuf_bindings
99
{
1010
cd "${ROOTDIR}"/test/tools/ossfuzz
1111
# Generate protobuf C++ bindings
@@ -15,7 +15,7 @@ generate_protobuf_bindings()
1515
done
1616
}
1717

18-
build_fuzzers()
18+
function build_fuzzers
1919
{
2020
cd "${BUILDDIR}"
2121
cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" \

scripts/ci/docker_upgrade.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
function error() {
4+
function error
5+
{
56
echo >&2 "ERROR: ${1} Aborting." && false
67
}
78

8-
function warning() {
9+
function warning
10+
{
911
echo >&2 "WARNING: ${1}"
1012
}
1113

scripts/common.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ _initial_work_dir=$(pwd)
2929
if [ "$CIRCLECI" ]
3030
then
3131
export TERM="${TERM:-xterm}"
32-
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
33-
function printError() { >&2 echo "$(tput setaf 1)$1$(tput setaf 7)"; }
34-
function printWarning() { >&2 echo "$(tput setaf 11)$1$(tput setaf 7)"; }
35-
function printLog() { echo "$(tput setaf 3)$1$(tput setaf 7)"; }
32+
function printTask { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
33+
function printError { >&2 echo "$(tput setaf 1)$1$(tput setaf 7)"; }
34+
function printWarning { >&2 echo "$(tput setaf 11)$1$(tput setaf 7)"; }
35+
function printLog { echo "$(tput setaf 3)$1$(tput setaf 7)"; }
3636
else
37-
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
38-
function printError() { >&2 echo "$(tput setaf 1)$1$(tput sgr0)"; }
39-
function printWarning() { >&2 echo "$(tput setaf 11)$1$(tput sgr0)"; }
40-
function printLog() { echo "$(tput setaf 3)$1$(tput sgr0)"; }
37+
function printTask { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
38+
function printError { >&2 echo "$(tput setaf 1)$1$(tput sgr0)"; }
39+
function printWarning { >&2 echo "$(tput setaf 11)$1$(tput sgr0)"; }
40+
function printLog { echo "$(tput setaf 3)$1$(tput sgr0)"; }
4141
fi
4242

4343
function printStackTrace
@@ -78,15 +78,15 @@ function printStackTrace
7878
done
7979
}
8080

81-
function fail()
81+
function fail
8282
{
8383
printError "$@"
8484

8585
# Using return rather than exit lets the invoking code handle the failure by suppressing the exit code.
8686
return 1
8787
}
8888

89-
function assertFail()
89+
function assertFail
9090
{
9191
printError ""
9292
(( $# == 0 )) && printError "Assertion failed."
@@ -97,7 +97,7 @@ function assertFail()
9797
exit 2
9898
}
9999

100-
function msg_on_error()
100+
function msg_on_error
101101
{
102102
local error_message
103103
local no_stdout=false
@@ -171,7 +171,7 @@ function msg_on_error()
171171
fi
172172
}
173173

174-
safe_kill()
174+
function safe_kill
175175
{
176176
local PID=${1}
177177
local NAME=${2:-${1}}

scripts/common_cmdline.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
YULARGS=(--strict-assembly)
2323
FULLARGS=(--optimize --combined-json "abi,asm,ast,bin,bin-runtime,devdoc,hashes,metadata,opcodes,srcmap,srcmap-runtime,userdoc")
2424
OLDARGS=(--optimize --combined-json "abi,asm,ast,bin,bin-runtime,devdoc,interface,metadata,opcodes,srcmap,srcmap-runtime,userdoc")
25-
function compileFull()
25+
26+
function compileFull
2627
{
2728
local expected_exit_code=0
2829
local expect_output='none'

scripts/docker_deploy_manual.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ else
2828
date -u +"nightly.%Y.%-m.%-d" > prerelease.txt
2929
fi
3030

31-
tag_and_push()
31+
function tag_and_push
3232
{
3333
docker tag "$image:$1" "$image:$2"
3434
docker push "$image:$2"

scripts/docs_version_pragma_check.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ source "${REPO_ROOT}/scripts/common_cmdline.sh"
3636

3737
developmentVersion=$("$REPO_ROOT/scripts/get_version.sh")
3838

39-
function versionGreater()
39+
function versionGreater
4040
{
4141
v1=$1
4242
v2=$2
@@ -58,7 +58,7 @@ function versionGreater()
5858
return 1
5959
}
6060

61-
function versionEqual()
61+
function versionEqual
6262
{
6363
if [[ "$1" == "$2" ]]
6464
then
@@ -67,7 +67,7 @@ function versionEqual()
6767
return 1
6868
}
6969

70-
function getAllAvailableVersions()
70+
function getAllAvailableVersions
7171
{
7272
allVersions=()
7373
local allListedVersions
@@ -85,7 +85,7 @@ function getAllAvailableVersions()
8585
done
8686
}
8787

88-
function findMinimalVersion()
88+
function findMinimalVersion
8989
{
9090
local f=$1
9191
local greater=false

scripts/solc-bin/bytecode_reports_for_modified_binaries.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@
5050
# FIXME: Can't use set -u because the old Bash on macOS treats empty arrays as unbound variables
5151
set -eo pipefail
5252

53-
die()
53+
function die
5454
{
5555
# shellcheck disable=SC2059
5656
>&2 printf "ERROR: $1\n" "${@:2}"
5757
exit 1
5858
}
5959

60-
get_reported_solc_version()
60+
function get_reported_solc_version
6161
{
6262
local solc_binary="$1"
6363

@@ -70,7 +70,7 @@ get_reported_solc_version()
7070
echo "$version_banner" | tail -n 1 | sed -n -E 's/^Version: (.*)$/\1/p'
7171
}
7272

73-
validate_reported_version()
73+
function validate_reported_version
7474
{
7575
local reported_version="$1"
7676
local expected_version_and_commit="$2"

scripts/soltest.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ BOOST_OPTIONS=()
88
SOLTEST_OPTIONS=()
99
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
1010

11-
usage() {
11+
function usage
12+
{
1213
echo 2>&1 "
1314
Usage: $0 [options] [soltest-options]
1415
Runs BOOST C++ unit test program, soltest.

scripts/test_antlr_grammar.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ SGR_BLUE="\033[34m"
2020
vt_cursor_up() { echo -ne "\033[A"; }
2121
vt_cursor_begin_of_line() { echo -ne "\r"; }
2222

23-
download_antlr4()
23+
function download_antlr4
2424
{
2525
if [[ ! -e "$ANTLR_JAR" ]]
2626
then
2727
curl -o "${ANTLR_JAR}" "${ANTLR_JAR_URI}"
2828
fi
2929
}
3030

31-
prepare_workdir()
31+
function prepare_workdir
3232
{
3333
mkdir -p "${ROOT_DIR}/build/deps"
3434
mkdir -p "${WORKDIR}"
@@ -51,7 +51,7 @@ javac -classpath "${ANTLR_JAR}" "${WORKDIR}/src/"*.java -d "${WORKDIR}/target/"
5151

5252
# Run tests
5353
failed_count=0
54-
test_file()
54+
function test_file
5555
{
5656
local SOL_FILE
5757
SOL_FILE="$(${READLINK} -m "${1}")"

scripts/tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ source "${REPO_ROOT}/scripts/common.sh"
3838
WORKDIR=$(mktemp -d)
3939
CMDLINE_PID=
4040

41-
cleanup() {
41+
function cleanup
42+
{
4243
# ensure failing commands don't cause termination during cleanup (especially within safe_kill)
4344
set +e
4445

scripts/wasm-rebuild/docker-scripts/rebuild_tags.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ ORANGE='\033[0;33m'
3838
CYAN='\033[0;36m'
3939
RESET='\033[0m'
4040

41-
function generate_bytecode_report() {
41+
function generate_bytecode_report
42+
{
4243
rm -rf /tmp/report.txt
4344

4445
local EXIT_STATUS
@@ -74,15 +75,17 @@ function generate_bytecode_report() {
7475
echo -e "${RED}FAILURE${RESET}"
7576
fi
7677
}
77-
function clean_git_checkout() {
78+
function clean_git_checkout
79+
{
7880
git submodule deinit --all -q
7981
git reset --hard HEAD --quiet
8082
git clean -f -d -x --quiet
8183
git checkout "$1" --quiet
8284
git submodule init -q
8385
git submodule update -q
8486
}
85-
function process_tag() {
87+
function process_tag
88+
{
8689
local TAG=$1
8790
cd /src
8891
# Checkout the historic commit instead of the tag directly.

scripts/yul_coverage.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ for arg in "$@"; do
8383
esac
8484
done
8585

86-
show_output_if() {
86+
function show_output_if
87+
{
8788
local VAR=${1}
8889
if [ -n "${VAR}" ]; then
8990
echo "${SOL_FILE}"
@@ -102,7 +103,8 @@ if [ ! -f "${SOLC}" ]; then
102103
exit 1
103104
fi
104105

105-
test_file() {
106+
function test_file
107+
{
106108
local SOL_FILE
107109
local OUTPUT
108110
SOL_FILE=${1}

test/cmdlineTests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function ask_expectation_update
154154

155155
# General helper function for testing SOLC behaviour, based on file name, compile opts, exit code, stdout and stderr.
156156
# An failure is expected.
157-
function test_solc_behaviour()
157+
function test_solc_behaviour
158158
{
159159
local filename="${1}"
160160
local solc_args
@@ -288,7 +288,7 @@ EOF
288288
}
289289

290290

291-
function test_solc_assembly_output()
291+
function test_solc_assembly_output
292292
{
293293
local input="${1}"
294294
local expected="${2}"

test/docsCodeStyle.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)
1010

1111
if [ "$CIRCLECI" ]
1212
then
13-
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
14-
function printError() { echo "$(tput setaf 1)$1$(tput setaf 7)"; }
13+
function printTask { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
14+
function printError { echo "$(tput setaf 1)$1$(tput setaf 7)"; }
1515
else
16-
function printTask() { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
17-
function printError() { echo "$(tput setaf 1)$1$(tput sgr0)"; }
16+
function printTask { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
17+
function printError { echo "$(tput setaf 1)$1$(tput sgr0)"; }
1818
fi
1919

2020
printTask "Checking docs examples style"

test/externalTests/common.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ function run_test
187187
$test_fn
188188
}
189189

190-
function optimizer_settings_for_level {
190+
function optimizer_settings_for_level
191+
{
191192
local level="$1"
192193

193194
case "$level" in
@@ -201,7 +202,8 @@ function optimizer_settings_for_level {
201202
esac
202203
}
203204

204-
function truffle_compiler_settings {
205+
function truffle_compiler_settings
206+
{
205207
local solc_path="$1"
206208
local level="$2"
207209
local evm_version="$3"

test/stopAfterParseTests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ FILETMP=$(mktemp -d)
1515
cd "$FILETMP" || exit 1
1616

1717

18-
function testFile()
18+
function testFile
1919
{
2020
set +e
2121
ALLOUTPUT=$($SOLC --combined-json ast --pretty-json "$@" --stop-after parsing 2>&1)

0 commit comments

Comments
 (0)