Skip to content

Commit abf57c2

Browse files
fix: address Copilot review feedback on bash scripts
- Add jq compact mode (-c) to preserve single-line JSON output - Use has_jq() from common.sh instead of inline command -v jq - Shell-escape BRANCH_NAME with printf '%q' in persistence hint
1 parent 8589227 commit abf57c2

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

scripts/bash/check-prerequisites.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if $PATHS_ONLY; then
8989
if $JSON_MODE; then
9090
# Minimal JSON paths payload (no validation performed)
9191
if has_jq; then
92-
jq -n \
92+
jq -cn \
9393
--arg repo_root "$REPO_ROOT" \
9494
--arg branch "$CURRENT_BRANCH" \
9595
--arg feature_dir "$FEATURE_DIR" \
@@ -160,7 +160,7 @@ if $JSON_MODE; then
160160
else
161161
json_docs=$(printf '%s\n' "${docs[@]}" | jq -R . | jq -s .)
162162
fi
163-
jq -n \
163+
jq -cn \
164164
--arg feature_dir "$FEATURE_DIR" \
165165
--argjson docs "$json_docs" \
166166
'{FEATURE_DIR:$feature_dir,AVAILABLE_DOCS:$docs}'

scripts/bash/create-new-feature.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,11 @@ SPEC_FILE="$FEATURE_DIR/spec.md"
301301
if [ -f "$TEMPLATE" ]; then cp "$TEMPLATE" "$SPEC_FILE"; else touch "$SPEC_FILE"; fi
302302

303303
# Inform the user how to persist the feature variable in their own shell
304-
echo "# To persist: export SPECIFY_FEATURE=$BRANCH_NAME" >&2
304+
printf '# To persist: export SPECIFY_FEATURE=%q\n' "$BRANCH_NAME" >&2
305305

306306
if $JSON_MODE; then
307-
if command -v jq >/dev/null 2>&1; then
308-
jq -n \
307+
if has_jq; then
308+
jq -cn \
309309
--arg branch_name "$BRANCH_NAME" \
310310
--arg spec_file "$SPEC_FILE" \
311311
--arg feature_num "$FEATURE_NUM" \

scripts/bash/setup-plan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fi
5252
# Output results
5353
if $JSON_MODE; then
5454
if has_jq; then
55-
jq -n \
55+
jq -cn \
5656
--arg feature_spec "$FEATURE_SPEC" \
5757
--arg impl_plan "$IMPL_PLAN" \
5858
--arg specs_dir "$FEATURE_DIR" \

0 commit comments

Comments
 (0)