From d2b96608ff9be57d77efecb44e74ea12a0ea12b1 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 29 Jul 2020 23:47:13 -0600 Subject: [PATCH] cleanup rg's install.sh --- rg/install.sh | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/rg/install.sh b/rg/install.sh index 990bfd2..3646e03 100644 --- a/rg/install.sh +++ b/rg/install.sh @@ -6,21 +6,33 @@ # Install ripgrep # ################### - new_rg="${HOME}/.local/bin/rg" - WEBI_SINGLE=true + # Every package should define these 6 variables + pkg_cmd_name="rg" - pkg_get_current_version() { - echo $(rg --version 2>/dev/null | head -n 1 | cut -d ' ' -f 2) - } + pkg_dst_cmd="$HOME/.local/bin/rg" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/rg-v$WEBI_VERSION/bin/rg" + pkg_src_dir="$HOME/.local/opt/rg-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" + # pkg_install must be defined by every package pkg_install() { - # ~/.local/opt/rg-v11.1.0/bin - mkdir -p "$pkg_src_bin" + # ~/.local/opt/rg-v12.1.1/bin + mkdir -p "$(dirname $pkg_src_cmd)" - # mv ./ripgrep-*/rg ~/.local/opt/rg-v11.1.0/bin/rg + # mv ./ripgrep-*/rg ~/.local/opt/rg-v12.1.1/bin/rg mv ./ripgrep-*/rg "$pkg_src_cmd" + } - # chmod a+x ~/.local/opt/rg-v11.1.0/bin/rg - chmod a+x "$pkg_src_cmd" + # pkg_get_current_version is recommended, but (soon) not required + pkg_get_current_version() { + # 'rg --version' has output in this format: + # ripgrep 12.1.1 (rev 7cb211378a) + # -SIMD -AVX (compiled) + # +SIMD -AVX (runtime) + # This trims it down to just the version number: + # 12.1.1 + echo $(rg --version 2>/dev/null | head -n 1 | cut -d ' ' -f 2) } } -- 2.25.1