From 290fc8b945243bda1e867694c5abd5ecfdf2bc18 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Fri, 15 Oct 2021 18:03:05 -0700 Subject: [PATCH] Have quickscripts search for relevant paths (fixes #2286) --- quickrun | 10 +++++++++- quicktest | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/quickrun b/quickrun index 172ae88..e0e0547 100755 --- a/quickrun +++ b/quickrun @@ -2,4 +2,12 @@ # quickrun runs ShellCheck in an interpreted mode. # This allows testing changes without recompiling. -runghc -isrc -idist/build/autogen shellcheck.hs "$@" +path=$(find . -type f -path './dist*/Paths_ShellCheck.hs' | sort | head -n 1) +if [ -z "$path" ] +then + echo >&2 "Unable to find Paths_ShellCheck.hs. Please 'cabal build' once." + exit 1 +fi +path="${path%/*}" + +exec runghc -isrc -i"$path" shellcheck.hs "$@" diff --git a/quicktest b/quicktest index 55041a7..6a1cf61 100755 --- a/quicktest +++ b/quicktest @@ -3,8 +3,17 @@ # This allows running tests without compiling, which can be faster. # 'cabal test' remains the source of truth. +path=$(find . -type f -path './dist*/Paths_ShellCheck.hs' | sort | head -n 1) +if [ -z "$path" ] +then + echo >&2 "Unable to find Paths_ShellCheck.hs. Please 'cabal build' once." + exit 1 +fi +path="${path%/*}" + + ( -var=$(echo 'main' | ghci test/shellcheck.hs 2>&1 | tee /dev/stderr) +var=$(echo 'main' | ghci -isrc -i"$path" test/shellcheck.hs 2>&1 | tee /dev/stderr) if [[ $var == *ExitSuccess* ]] then exit 0