Skip to content

Commit 14c46da

Browse files
committed
Add add and run shell formatter
1 parent 7a5ef83 commit 14c46da

File tree

9 files changed

+25
-23
lines changed

9 files changed

+25
-23
lines changed

devtools/check_contracts_fast.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
3-
command -v shellcheck > /dev/null && shellcheck "$0"
3+
command -v shellcheck >/dev/null && shellcheck "$0"
44

55
for contract_dir in contracts/*/; do
66
(

devtools/check_contracts_full.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
3-
command -v shellcheck > /dev/null && shellcheck "$0"
3+
command -v shellcheck >/dev/null && shellcheck "$0"
44

55
for contract_dir in contracts/*/; do
66
(

devtools/check_contracts_medium.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
3-
command -v shellcheck > /dev/null && shellcheck "$0"
3+
command -v shellcheck >/dev/null && shellcheck "$0"
44

55
for contract_dir in contracts/*/; do
66
(

devtools/check_workspace.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
3-
command -v shellcheck > /dev/null && shellcheck "$0"
3+
command -v shellcheck >/dev/null && shellcheck "$0"
44

55
cargo fmt
66
(cd packages/crypto && cargo build && cargo test && cargo clippy -- -D warnings)

devtools/format_md.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
3-
command -v shellcheck > /dev/null && shellcheck "$0"
3+
command -v shellcheck >/dev/null && shellcheck "$0"
44

55
npx [email protected] --write --prose-wrap always "./**/*.md"

devtools/format_sh.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -o errexit -o nounset -o pipefail
3+
command -v shellcheck >/dev/null && shellcheck "$0"
4+
5+
shfmt -w devtools packages

devtools/format_yml.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
3-
command -v shellcheck > /dev/null && shellcheck "$0"
3+
command -v shellcheck >/dev/null && shellcheck "$0"
44

55
npx [email protected] --write "./**/*.yml"

devtools/set_version.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
3-
command -v shellcheck > /dev/null && shellcheck "$0"
3+
command -v shellcheck >/dev/null && shellcheck "$0"
44

55
gnused="$(command -v gsed || echo sed)"
66

@@ -11,8 +11,8 @@ function print_usage() {
1111
}
1212

1313
if [ "$#" -ne 1 ]; then
14-
print_usage
15-
exit 1
14+
print_usage
15+
exit 1
1616
fi
1717

1818
# Check repo
@@ -25,9 +25,9 @@ fi
2525
# Ensure repo is not dirty
2626
CHANGES_IN_REPO=$(git status --porcelain)
2727
if [[ -n "$CHANGES_IN_REPO" ]]; then
28-
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
29-
git status && git --no-pager diff
30-
exit 3
28+
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
29+
git status && git --no-pager diff
30+
exit 3
3131
fi
3232

3333
NEW="$1"

packages/vm/examples/module_size.sh

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ PROFILE="release"
1111
MEM_UTIL="valgrind --tool=massif --max-snapshots=$MAX_SNAPSHOTS"
1212
SUM_UTIL="ms_print"
1313

14-
PROG=`basename $0 .sh`
15-
BASE_DIR=`dirname $0`/..
14+
PROG=$(basename $0 .sh)
15+
BASE_DIR=$(dirname $0)/..
1616

1717
# Look for the useful info
1818
FNS="module_compile module_deserialize"
@@ -22,8 +22,7 @@ BIN="$BASE_DIR/../../target/$PROFILE/examples/$PROG"
2222
RESULTS="$BASE_DIR/$PROG.log"
2323
SUMMARY="$BASE_DIR/ms_print.log"
2424

25-
if [ "$PROFILE" = "release" ]
26-
then
25+
if [ "$PROFILE" = "release" ]; then
2726
RUSTFLAGS="-g" cargo build --release --example module_size
2827
else
2928
cargo build --example module_size
@@ -32,18 +31,16 @@ fi
3231
$MEM_UTIL --massif-out-file=$RESULTS $BIN $WASM
3332
$SUM_UTIL $RESULTS >$SUMMARY
3433

35-
for FN in $FNS
36-
do
34+
for FN in $FNS; do
3735
# Try to compute $FN() total (heap) bytes
38-
LAST_LINE=`grep -n "::$FN " $SUMMARY| tail -1 | cut -f1 -d:`
39-
if [ -z "$LAST_LINE" ]
40-
then
36+
LAST_LINE=$(grep -n "::$FN " $SUMMARY | tail -1 | cut -f1 -d:)
37+
if [ -z "$LAST_LINE" ]; then
4138
echo -n "'$FN' not found. "
4239
[ $MAX_SNAPSHOTS -lt 1000 ] && echo "Try increasing MAX_SNAPSHOTS (current: $MAX_SNAPSHOTS, max: 1000). " || echo "Try again."
4340
continue
4441
fi
45-
TOTAL_LINES=`wc -l $SUMMARY | cut -f1 -d\ `
46-
START_LINE=$[TOTAL_LINES - $LAST_LINE + 1]
42+
TOTAL_LINES=$(wc -l $SUMMARY | cut -f1 -d\ )
43+
START_LINE=$((TOTAL_LINES - $LAST_LINE + 1))
4744
echo -n "module size ($FN): "
4845
tac $SUMMARY | sed -n "$START_LINE,/^ n /p" | grep "::$FN " | cut -f2 -d\( | cut -f1 -d\) | sort -u | sed 's/,//g;s/B//' | sed ':a;N;s/\n/+/;ta' | bc -l | sed 's/$/ bytes/'
4946
done

0 commit comments

Comments
 (0)