Skip to content

Commit f14ac2a

Browse files
committed
fix: strip CRLF from jq output for Windows compatibility
On Windows Git Bash, jq outputs CRLF line endings which causes dependency names to include trailing carriage returns. This breaks skill resolution when looking for directories like 'nanobanana\r'. Add strip_cr() helper function and pipe all jq output through it. Fixes #2
1 parent 5db1a53 commit f14ac2a

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

install.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ INSTALLED_SKILLS=""
6363
SKILLS_JSON_PATH=""
6464
SKILLS_JSON_CONTENT=""
6565

66+
# Strip carriage returns for Windows compatibility (Git Bash outputs CRLF)
67+
strip_cr() {
68+
tr -d '\r'
69+
}
70+
6671
# Check if jq is available
6772
check_jq() {
6873
if command -v jq &> /dev/null; then
@@ -106,7 +111,7 @@ load_skills_json() {
106111
# Get all available skill names from skills.json
107112
get_available_skills() {
108113
load_skills_json || return 1
109-
echo "$SKILLS_JSON_CONTENT" | jq -r '.skills[].name' | tr '\n' ' '
114+
echo "$SKILLS_JSON_CONTENT" | jq -r '.skills[].name' | strip_cr | tr '\n' ' '
110115
}
111116

112117
# Validate if a skill exists in skills.json
@@ -122,15 +127,15 @@ get_skill_deps() {
122127
local skill=$1
123128
load_skills_json || return 1
124129
echo "$SKILLS_JSON_CONTENT" | jq -r --arg s "$skill" \
125-
'.skills[] | select(.name == $s) | .dependencies // [] | .[]' 2>/dev/null | tr '\n' ' '
130+
'.skills[] | select(.name == $s) | .dependencies // [] | .[]' 2>/dev/null | strip_cr | tr '\n' ' '
126131
}
127132

128133
# Get skill description from skills.json
129134
get_skill_description() {
130135
local skill=$1
131136
load_skills_json || return 1
132137
echo "$SKILLS_JSON_CONTENT" | jq -r --arg s "$skill" \
133-
'.skills[] | select(.name == $s) | .description // ""' 2>/dev/null
138+
'.skills[] | select(.name == $s) | .description // ""' 2>/dev/null | strip_cr
134139
}
135140

136141
# Check if skill requires authentication
@@ -139,7 +144,7 @@ skill_requires_auth() {
139144
load_skills_json || return 1
140145

141146
local required=$(echo "$SKILLS_JSON_CONTENT" | jq -r --arg s "$skill" \
142-
'.skills[] | select(.name == $s) | .auth.required // false' 2>/dev/null)
147+
'.skills[] | select(.name == $s) | .auth.required // false' 2>/dev/null | strip_cr)
143148

144149
if [ "$required" = "true" ]; then
145150
return 0 # true - requires auth
@@ -153,23 +158,23 @@ get_skill_env_var() {
153158
local skill=$1
154159
load_skills_json || return 1
155160
echo "$SKILLS_JSON_CONTENT" | jq -r --arg s "$skill" \
156-
'.skills[] | select(.name == $s) | .auth.env_var // empty' 2>/dev/null
161+
'.skills[] | select(.name == $s) | .auth.env_var // empty' 2>/dev/null | strip_cr
157162
}
158163

159164
# Get auth note/instructions for skill
160165
get_skill_auth_note() {
161166
local skill=$1
162167
load_skills_json || return 1
163168
echo "$SKILLS_JSON_CONTENT" | jq -r --arg s "$skill" \
164-
'.skills[] | select(.name == $s) | .auth.note // empty' 2>/dev/null
169+
'.skills[] | select(.name == $s) | .auth.note // empty' 2>/dev/null | strip_cr
165170
}
166171

167172
# Get example URL for skill from links.example
168173
get_skill_example_url() {
169174
local skill=$1
170175
load_skills_json || return 1
171176
echo "$SKILLS_JSON_CONTENT" | jq -r --arg s "$skill" \
172-
'.skills[] | select(.name == $s) | .links.example // empty' 2>/dev/null
177+
'.skills[] | select(.name == $s) | .links.example // empty' 2>/dev/null | strip_cr
173178
}
174179

175180
# Detect user's shell profile
@@ -357,7 +362,7 @@ show_help() {
357362
# Dynamically list skills from skills.json
358363
load_skills_json 2>/dev/null
359364
if [ -n "$SKILLS_JSON_CONTENT" ]; then
360-
echo "$SKILLS_JSON_CONTENT" | jq -r '.skills[] | " \(.name | . + " " * (15 - length)) \(.description | .[0:50])..."' 2>/dev/null || {
365+
echo "$SKILLS_JSON_CONTENT" | jq -r '.skills[] | " \(.name | . + " " * (15 - length)) \(.description | .[0:50])..."' 2>/dev/null | strip_cr || {
361366
echo " (run with -h after jq is installed to see skill list)"
362367
}
363368
else
@@ -588,13 +593,13 @@ if [ -z "$SKILL" ]; then
588593

589594
# Build dynamic menu from skills.json
590595
load_skills_json
591-
SKILL_NAMES=$(echo "$SKILLS_JSON_CONTENT" | jq -r '.skills[].name')
596+
SKILL_NAMES=$(echo "$SKILLS_JSON_CONTENT" | jq -r '.skills[].name' | strip_cr)
592597
SKILL_COUNT=$(echo "$SKILL_NAMES" | wc -l | xargs)
593598

594599
local i=1
595600
while IFS= read -r skill_name; do
596601
local desc=$(echo "$SKILLS_JSON_CONTENT" | jq -r --arg s "$skill_name" \
597-
'.skills[] | select(.name == $s) | .description | .[0:40]' 2>/dev/null)
602+
'.skills[] | select(.name == $s) | .description | .[0:40]' 2>/dev/null | strip_cr)
598603
printf " %d) %-15s - %s...\n" "$i" "$skill_name" "$desc"
599604
((i++))
600605
done <<< "$SKILL_NAMES"

0 commit comments

Comments
 (0)