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:
parent
ee61574612
commit
12ab1988f7
1 changed files with 4 additions and 2 deletions
|
|
@ -268,9 +268,10 @@ download_picoclaw() {
|
|||
if [ "$version" = "latest" ]; then
|
||||
msg "$BLUE" "Fetching latest version..."
|
||||
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
|
||||
version=$(echo "$json" | jq -r '.tag_name')
|
||||
else
|
||||
version=$(echo "$json" | grep -m1 '"tag_name"' | cut -d'"' -f4)
|
||||
fi
|
||||
else
|
||||
msg "$BLUE" "Fetching version $version..."
|
||||
|
|
@ -382,9 +383,10 @@ install_picoclaw() {
|
|||
if [ "$version" = "latest" ]; then
|
||||
msg "$BLUE" "Fetching latest version..."
|
||||
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
|
||||
version=$(echo "$json" | jq -r '.tag_name')
|
||||
else
|
||||
version=$(echo "$json" | grep -m1 '"tag_name"' | cut -d'"' -f4)
|
||||
fi
|
||||
else
|
||||
msg "$BLUE" "Fetching version $version..."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue