Skip to content

Commit cc10228

Browse files
committed
fix(upgrade): tools disappearing due to empty sort key bug
In sort_tools_runtime_first(), non-runtime tools had sort_key="" (empty), causing echo "$sort_key $tool" to output " shellcheck" with a leading space. When awk processed this, $1 was the tool name and $2 was empty, causing all non-runtime tools to be lost. Fixed by initializing sort_key="999" so all tools have a valid sort key and are preserved through the sort | awk pipeline.
1 parent ecc2ecf commit cc10228

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

scripts/guide.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,20 +544,18 @@ sort_tools_runtime_first() {
544544
local runtimes="python node php go ruby rust"
545545

546546
for tool in $tools; do
547-
local priority=100
548-
local sort_key=""
547+
local sort_key="999" # Default: other tools sort last
549548

550549
# Check if tool is a base runtime
551550
for rt in $runtimes; do
552551
if [ "$tool" = "$rt" ]; then
553-
priority=0
554552
sort_key="000"
555553
break
556554
fi
557555
done
558556

559557
# Check if tool is a multi-version runtime (e.g., python@3.14)
560-
if [ "$priority" = "100" ] && [[ "$tool" == *"@"* ]]; then
558+
if [ "$sort_key" = "999" ] && [[ "$tool" == *"@"* ]]; then
561559
local base="${tool%%@*}"
562560
local version="${tool##*@}"
563561
for rt in $runtimes; do
@@ -568,7 +566,6 @@ sort_tools_runtime_first() {
568566
local minor="${version#*.}"
569567
minor="${minor%%.*}"
570568
# Invert so higher versions sort first
571-
priority=1
572569
sort_key=$(printf "%03d" $((999 - major * 10 - minor)))
573570
break
574571
fi

0 commit comments

Comments
 (0)