Skip to content

Commit

Permalink
Compute version_prefix using awk
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella committed Jul 4, 2024
1 parent 622c0fd commit d0be5a8
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,15 @@ ghcup_wrapper() {
}

list_all_versions() {
ghcup_wrapper list -t "$1" -r | awk '{printf $2" "}'
}

ver() {
echo "$1" | awk -F . '{ printf("%02d%02d", $1,$2); }'
ghcup_wrapper list -t "$1" -r | awk '{printf $2 " "}'
}

install_version() {
local tool="$1"
local version="$2"
local path="$3"

local version_prefix=$(echo "$version" | cut -d '.' -f 1,2)
local version_prefix=$(echo "$version" | awk -F. '{print $1 "." $2}')

if [[ $tool == "ghc" ]] || { [[ $tool == "hls" ]] && [[ $(echo "$version_prefix >= 1.7" | bc) -eq 1 ]]; }; then
ghcup_wrapper install "$tool" "$version" -i "$path"
Expand Down

0 comments on commit d0be5a8

Please sign in to comment.