3 # Copyright (c) 2019 The Tor Project, Inc.
4 # See LICENSE for license information
8 # If shellcheck is installed, check all the shell scripts that we can fix.
12 # Only run this script if shellcheck is installed
13 # command echoes the path to shellcheck, which is a useful diagnostic log
14 if ! command -v shellcheck
; then
15 printf "%s: Install shellcheck to check shell scripts.\\n" "$0"
19 # Some platforms don't have realpath
20 if command -v realpath
; then
21 HERE
=$
(dirname "$(realpath "$0")")
24 if [ ! -d "$HERE" ] ||
[ "$HERE" = "." ]; then
25 HERE
=$
(dirname "$PWD/$0")
28 TOPLEVEL
=$
(dirname "$(dirname "$HERE")")
30 # Check we actually have a tor/src directory
31 if [ ! -d "$TOPLEVEL/src" ]; then
32 printf "Error: Couldn't find src directory in expected location: %s\\n" \
37 # Remove obsolete scripts generated from older versions of Tor
38 rm -f "$TOPLEVEL/contrib/dist/suse/tor.sh" "$TOPLEVEL/contrib/dist/tor.sh"
40 # Check *.sh scripts, but ignore the ones that we can't fix
41 find "$TOPLEVEL/contrib" "$TOPLEVEL/doc" "$TOPLEVEL/scripts" "$TOPLEVEL/src" \
43 -not -path "$TOPLEVEL/src/ext/*" \
44 -not -path "$TOPLEVEL/src/rust/registry/*" \
47 # Check scripts that aren't named *.sh
48 if [ -d "$TOPLEVEL/scripts/test" ]; then
50 "$TOPLEVEL/scripts/test/cov-diff" \
51 "$TOPLEVEL/scripts/test/coverage"
54 "$TOPLEVEL/contrib/dirauth-tools/nagios-check-tor-authority-cert" \
57 "$TOPLEVEL/contrib/dirauth-tools/nagios-check-tor-authority-cert"
59 if [ -e "$TOPLEVEL/contrib/client-tools/torify" ]; then
60 shellcheck
"$TOPLEVEL/contrib/client-tools/torify"
62 if [ -d "$TOPLEVEL/scripts/git" ]; then
63 shellcheck
"$TOPLEVEL/scripts/git/"*.git-hook