fix: optimize version extraction in install.sh

Check for jq first before falling back to grep, avoiding
redundant extraction when jq is available.

Generated with [Z.ai](https://z.ai/subscribe?ic=JGTYCX7ZO7)

Co-Authored-By: Z.ai GLM-5
This commit is contained in:
Kadic Mirzet 2026-02-22 10:05:02 +01:00
parent ee61574612
commit 12ab1988f7

View file

@ -268,9 +268,10 @@ download_picoclaw() {
if [ "$version" = "latest" ]; then if [ "$version" = "latest" ]; then
msg "$BLUE" "Fetching latest version..." msg "$BLUE" "Fetching latest version..."
json=$(download_file "${GITHUB_API}/releases/latest") json=$(download_file "${GITHUB_API}/releases/latest")
version=$(echo "$json" | grep -m1 '"tag_name"' | cut -d'"' -f4)
if command -v jq >/dev/null 2>&1; then if command -v jq >/dev/null 2>&1; then
version=$(echo "$json" | jq -r '.tag_name') version=$(echo "$json" | jq -r '.tag_name')
else
version=$(echo "$json" | grep -m1 '"tag_name"' | cut -d'"' -f4)
fi fi
else else
msg "$BLUE" "Fetching version $version..." msg "$BLUE" "Fetching version $version..."
@ -382,9 +383,10 @@ install_picoclaw() {
if [ "$version" = "latest" ]; then if [ "$version" = "latest" ]; then
msg "$BLUE" "Fetching latest version..." msg "$BLUE" "Fetching latest version..."
json=$(download_file "${GITHUB_API}/releases/latest") json=$(download_file "${GITHUB_API}/releases/latest")
version=$(echo "$json" | grep -m1 '"tag_name"' | cut -d'"' -f4)
if command -v jq >/dev/null 2>&1; then if command -v jq >/dev/null 2>&1; then
version=$(echo "$json" | jq -r '.tag_name') version=$(echo "$json" | jq -r '.tag_name')
else
version=$(echo "$json" | grep -m1 '"tag_name"' | cut -d'"' -f4)
fi fi
else else
msg "$BLUE" "Fetching version $version..." msg "$BLUE" "Fetching version $version..."