Skip to content

Commit 8635352

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 78344c3 commit 8635352

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

META.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ META=META.yml
1717
# Manual extraction of metadata with basic cmd line tools
1818
VAL=$(cat $META |
1919
grep "name\|$2" |
20-
grep $1 -A 1 |
21-
grep $2 |
20+
grep "$1" -A 1 |
21+
grep "$2" |
2222
cut -d ":" -f 2 | tr -d ' ')
2323

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

30-
if [[ $VAL_JQ != $VAL ]]; then
30+
if [[ $VAL_JQ != "$VAL" ]]; then
3131
echo "ERROR parsing metadata file $META"
3232
exit 1
3333
fi
@@ -43,5 +43,5 @@ if [[ $INPUT != "" ]]; then
4343
exit 0
4444
fi
4545
else
46-
echo $VAL
46+
echo "$VAL"
4747
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/x86_64/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/x86_64/mldsa/*.S | cut -d '/' -f 5 | sed 's/\.S//'

proofs/hol_light/x86_64/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: 7 additions & 9 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,36 +27,36 @@ 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
44-
shfmt -s -w -l -i 2 -ci -fn $(shfmt -f $(git grep -l '' :/))
42+
shfmt -s -w -l -i 2 -ci -fn "$(shfmt -f "$(git grep -l '' :/)")"
4543

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

5351
info "Formatting c files"
54-
if ! command -v clang-format 2>&1 >/dev/null; then
52+
if ! command -v clang-format >/dev/null 2>&1; then
5553
error "clang-format not found. Are you running in a nix shell? See BUILDING.md."
5654
exit 1
5755
fi
5856

5957
nproc=$(getconf _NPROCESSORS_ONLN || echo 1)
6058

61-
git ls-files -- ":/*.c" ":/*.h" | xargs -P $nproc -I {} sh -c '
59+
git ls-files -- ":/*.c" ":/*.h" | xargs -P "$nproc" -I {} sh -c '
6260
# Ignore symlinks
6361
if [[ ! -L {} ]]; then
6462
clang-format -i {}
@@ -67,7 +65,7 @@ git ls-files -- ":/*.c" ":/*.h" | xargs -P $nproc -I {} sh -c '
6765
info "Checking for eol"
6866
check-eol()
6967
{
70-
git ls-files -- ":/" ":/!:*.png" | xargs -P $nproc -I {} sh -c '
68+
git ls-files -- ":/" ":/!:*.png" | xargs -P "$nproc" -I {} sh -c '
7169
# Ignore symlinks
7270
if [[ ! -L {} && $(tail -c1 "{}" | wc -l) == 0 ]]; then
7371
echo "" >>"{}"

0 commit comments

Comments
 (0)