diff --git a/bin/install b/bin/install index 6aa2ef5..a0f92ee 100755 --- a/bin/install +++ b/bin/install @@ -2,13 +2,8 @@ set -euo pipefail -check_ghcup() { - if ! command -v ghcup &> /dev/null - then - echo "ghcup not found, installing..." - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh - fi -} +# shellcheck source=../lib/utils.sh +source "$(dirname "$0")/../lib/utils.sh" ver() { echo "${1}" | awk -F . '{ printf("%02d%02d", $1,$2); }' diff --git a/bin/list-all b/bin/list-all index dc82d80..8861179 100755 --- a/bin/list-all +++ b/bin/list-all @@ -2,13 +2,8 @@ set -euo pipefail -check_ghcup() { - if ! command -v ghcup &> /dev/null - then - echo "ghcup not found, installing..." - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh - fi -} +# shellcheck source=../lib/utils.sh +source "$(dirname "$0")/../lib/utils.sh" main() { check_ghcup diff --git a/lib/utils.sh b/lib/utils.sh new file mode 100644 index 0000000..9ab2046 --- /dev/null +++ b/lib/utils.sh @@ -0,0 +1,7 @@ +check_ghcup() { + if ! command -v ghcup &> /dev/null + then + echo "GHCup not found, installing..." + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | env BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh + fi +}