Skip to content

Commit 5624f82

Browse files
committed
linting: shell: fix shellcheck warnings
Fix errors brought up by the linter. Signed-off-by: Andreas Hatziiliou <andreas.hatziiliou@savoirfairelinux.com>
1 parent 465153e commit 5624f82

File tree

6 files changed

+18
-21
lines changed

6 files changed

+18
-21
lines changed

META.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ VAL=$(cat $META |
2020
cut -d ":" -f 2 | tr -d ' ')
2121

2222
# More robust extraction using yq
23-
if (which yq 2>&1 >/dev/null); then
23+
if (which yq >/dev/null 2>&1); then
2424
QUERY=".implementations | .[] | select(.name==\"$1\") | .\"$2\""
25-
echo "cat $META | yq "$QUERY" -r"
25+
echo "cat $META | yq \"$QUERY\" -r"
2626
VAL_JQ=$(cat $META | yq "$QUERY" -r)
2727

28-
if [[ $VAL_JQ != $VAL ]]; then
28+
if [[ $VAL_JQ != "$VAL" ]]; then
2929
echo "ERROR parsing metadata file $META"
3030
exit 1
3131
fi
@@ -41,5 +41,5 @@ if [[ $INPUT != "" ]]; then
4141
exit 0
4242
fi
4343
else
44-
echo $VAL
44+
echo "$VAL"
4545
fi

proofs/cbmc/list_proofs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
# which are those containing a *harness.c file.
77

88
ROOT=$(git rev-parse --show-toplevel)
9-
cd $ROOT
9+
cd "$ROOT" || exit
1010
ls -1 proofs/cbmc/**/*harness.c | cut -d '/' -f 3

proofs/hol_light/arm/list_proofs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
# we have a spec and proof in HOL-Light.
77

88
ROOT=$(git rev-parse --show-toplevel)
9-
cd $ROOT
9+
cd "$ROOT" || exit
1010
ls -1 proofs/hol_light/arm/mlkem/*.S | cut -d '/' -f 5 | sed 's/\.S//'

proofs/hol_light/arm/proofs/build-proof.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ output_path=$3
3434
output_dir=$(dirname "$output_path")
3535
[ -d "$output_dir" ] || mkdir -p "$output_dir"
3636

37-
export HOLLIGHT_DIR="$(dirname ${hol_sh_cmd})"
37+
HOLLIGHT_DIR="$(dirname "${hol_sh_cmd}")"
38+
export HOLLIGHT_DIR
3839
if [ ! -f "${HOLLIGHT_DIR}/hol_lib.cmxa" ]; then
3940
echo "hol_lib.cmxa does not exist in HOLLIGHT_DIR('${HOLLIGHT_DIR}')."
4041
echo "Did you compile HOL Light with HOLLIGHT_USE_MODULE set to 1?"
@@ -50,20 +51,20 @@ echo "Generating a template .ml that loads the file...: ${template_ml}"
5051
echo "check_axioms ();;"
5152
echo 'let proof_end_time = Unix.time();;'
5253
echo 'Printf.printf "Running time: %f sec, Start unixtime: %f, End unixtime: %f\n" (proof_end_time -. proof_start_time) proof_start_time proof_end_time;;'
53-
) >>${template_ml}
54+
) >>"${template_ml}"
5455

5556
inlined_prefix="$(mktemp)"
5657
inlined_ml="${inlined_prefix}.ml"
5758
inlined_cmx="${inlined_prefix}.cmx"
58-
(cd "${S2N_BIGNUM_DIR}" && HOLLIGHT_LOAD_PATH=${ROOT} ocaml ${HOLLIGHT_DIR}/inline_load.ml "${template_ml}" "${inlined_ml}")
59+
(cd "${S2N_BIGNUM_DIR}" && HOLLIGHT_LOAD_PATH=${ROOT} ocaml "${HOLLIGHT_DIR}"/inline_load.ml "${template_ml}" "${inlined_ml}")
5960

6061
# Give a large stack size.
6162
OCAMLRUNPARAM=l=2000000000 \
6263
ocamlopt.byte -pp "$(${hol_sh_cmd} -pp)" -I "${HOLLIGHT_DIR}" -I +unix -c \
63-
hol_lib.cmxa ${inlined_ml} -o ${inlined_cmx} -w -a
64+
hol_lib.cmxa "${inlined_ml}" -o "${inlined_cmx}" -w -a
6465
ocamlfind ocamlopt -package zarith,unix -linkpkg hol_lib.cmxa \
65-
-I "${HOLLIGHT_DIR}" ${inlined_cmx} \
66+
-I "${HOLLIGHT_DIR}" "${inlined_cmx}" \
6667
-o "${output_path}"
6768

6869
# Remove the intermediate files to save disk space
69-
rm -f ${inlined_cmx} ${template_ml} ${inlined_ml}
70+
rm -f "${inlined_cmx}" "${template_ml}" "${inlined_ml}"

scripts/format

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ ROOT="$(realpath "$(dirname "$0")"/../)"
1313
# Standard color definitions
1414
GREEN="\033[32m"
1515
RED="\033[31m"
16-
BLUE="\033[94m"
17-
BOLD="\033[1m"
1816
NORMAL="\033[0m"
1917

2018
# utility
@@ -29,15 +27,15 @@ error()
2927
}
3028

3129
info "Formatting nix files"
32-
if ! command -v nixpkgs-fmt 2>&1 >/dev/null; then
30+
if ! command -v nixpkgs-fmt >/dev/null 2>&1; then
3331
error "nixpkgs-fmt not found. Are you running in a nix shell? See BUILDING.md."
3432
exit 1
3533
fi
3634

3735
nixpkgs-fmt "$ROOT"
3836

3937
info "Formatting shell scripts"
40-
if ! command -v shfmt 2>&1 >/dev/null; then
38+
if ! command -v shfmt >/dev/null 2>&1; then
4139
error "shfmt not found. Are you running in a nix shell? See BUILDING.md."
4240
exit 1
4341
fi
@@ -48,14 +46,14 @@ SHELL_SCRIPTS=$(echo "$ALL_FILES" | xargs shfmt -f)
4846
shfmt -s -l -i 2 -ci -fn $SHELL_SCRIPTS
4947

5048
info "Formatting python scripts"
51-
if ! command -v black 2>&1 >/dev/null; then
49+
if ! command -v black >/dev/null 2>&1; then
5250
error "black not found. Are you running in a nix shell? See BUILDING.md."
5351
exit 1
5452
fi
5553
black --include "(scripts/tests|scripts/simpasm|scripts/cfify|scripts/autogen|scripts/check-namespace|\.py$)" "$ROOT"
5654

5755
info "Formatting c files"
58-
if ! command -v clang-format 2>&1 >/dev/null; then
56+
if ! command -v clang-format >/dev/null 2>&1; then
5957
error "clang-format not found. Are you running in a nix shell? See BUILDING.md."
6058
exit 1
6159
fi

scripts/lint

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ fi
2020
# Standard color definitions
2121
GREEN="\033[32m"
2222
RED="\033[31m"
23-
BLUE="\033[94m"
24-
BOLD="\033[1m"
2523
NORMAL="\033[0m"
2624

2725
info()
@@ -151,7 +149,7 @@ fi
151149
gh_group_end
152150

153151
gh_group_start "Linting c files with clang-format"
154-
checkerr "Lint C" "$(clang-format $(git ls-files ":/*.c" ":/*.h") --Werror --dry-run 2>&1 | grep "error:" | cut -d ':' -f 1,2 | tr ':' ' ')"
152+
checkerr "Lint C" "$(clang-format "$(git ls-files ":/*.c" ":/*.h")" --Werror --dry-run 2>&1 | grep "error:" | cut -d ':' -f 1,2 | tr ':' ' ')"
155153
gh_group_end
156154

157155
check-eol-dry-run()

0 commit comments

Comments
 (0)