@@ -68,7 +68,8 @@ get_repo_root() {
6868 fi
6969
7070 # Final fallback to script location
71- local script_dir=" $( CDPATH=" " cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
71+ local script_dir
72+ script_dir=" $( CDPATH=" " cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
7273 (cd " $script_dir /../../.." && pwd)
7374}
7475
@@ -95,7 +96,10 @@ get_current_branch() {
9596read_feature_json_feature_directory () {
9697 local repo_root=" $1 "
9798 local fj=" $repo_root /.specify/feature.json"
98- [[ -f " $fj " ]] || { printf ' %s' ' ' ; return 0; }
99+ [[ -f " $fj " ]] || {
100+ printf ' %s' ' '
101+ return 0
102+ }
99103
100104 # Try parsers in order (jq -> python3 -> grep/sed), falling through on
101105 # failure. Selection is by *parse success*, not mere availability: on
@@ -119,9 +123,9 @@ read_feature_json_feature_directory() {
119123 if [[ -z " $_fd " ]]; then
120124 # Last-resort single-line grep/sed fallback. The `|| true` guards against
121125 # grep returning 1 (no match) aborting under `set -e` / `pipefail`.
122- _fd=$( { grep -E ' "feature_directory"[[:space:]]*:' " $fj " 2> /dev/null || true ; } \
123- | head -n 1 \
124- | sed -E ' s/^[^:]*:[[:space:]]*"([^"]*)".*$/\1/' )
126+ _fd=$( { grep -E ' "feature_directory"[[:space:]]*:' " $fj " 2> /dev/null || true ; } |
127+ head -n 1 |
128+ sed -E ' s/^[^:]*:[[:space:]]*"([^"]*)".*$/\1/' )
125129 fi
126130
127131 printf ' %s' " $_fd "
@@ -154,9 +158,9 @@ _persist_feature_json() {
154158
155159 # Write feature.json — prefer jq for safe JSON, fall back to printf
156160 if command -v jq > /dev/null 2>&1 ; then
157- jq -cn --arg fd " $feature_dir_value " ' {feature_directory:$fd}' > " $fj "
161+ jq -cn --arg fd " $feature_dir_value " ' {feature_directory:$fd}' > " $fj "
158162 else
159- printf ' {"feature_directory":"%s"}\n' " $( json_escape " $feature_dir_value " ) " > " $fj "
163+ printf ' {"feature_directory":"%s"}\n' " $( json_escape " $feature_dir_value " ) " > " $fj "
160164 fi
161165}
162166
@@ -266,14 +270,18 @@ get_invoke_separator() {
266270 local jq_separator
267271 if jq_separator=$( jq -r ' (.default_integration // .integration // "") as $k | if $k == "" then "." else (.integration_settings[$k].invoke_separator // ".") end' " $integration_json " 2> /dev/null) ; then
268272 case " $jq_separator " in
269- " ." |" -" ) separator=" $jq_separator " ; parsed=1 ;;
273+ " ." | " -" )
274+ separator=" $jq_separator "
275+ parsed=1
276+ ;;
270277 esac
271278 fi
272279 fi
273280
274281 if [[ " $parsed " -eq 0 ]] && command -v python3 > /dev/null 2>&1 ; then
275282 local py_separator
276- if py_separator=$( python3 - " $integration_json " << 'PY ' 2>/dev/null
283+ if py_separator=$(
284+ python3 - " $integration_json " << 'PY ' 2>/dev/null
277285import json
278286import sys
279287
@@ -291,9 +299,12 @@ try:
291299except Exception:
292300 sys.exit(1)
293301PY
294- ) ; then
302+ ) ; then
295303 case " $py_separator " in
296- " ." |" -" ) separator=" $py_separator " ; parsed=1 ;;
304+ " ." | " -" )
305+ separator=" $py_separator "
306+ parsed=1
307+ ;;
297308 esac
298309 fi
299310 fi
344355 }
345356 ' " $integration_json " 2> /dev/null)
346357 case " $awk_separator " in
347- " ." | " -" ) separator=" $awk_separator " ;;
358+ " ." | " -" ) separator=" $awk_separator " ;;
348359 esac
349360 fi
350361 fi
@@ -391,10 +402,10 @@ json_escape() {
391402 # so multi-byte UTF-8 sequences (first byte >= 0xC0) pass through intact.
392403 local LC_ALL=C
393404 local i char code
394- for (( i = 0 ; i< ${# s} ; i++ )) ; do
405+ for (( i = 0 ; i < ${# s} ; i++ )) ; do
395406 char=" ${s: $i : 1} "
396407 printf -v code ' %d' " '$char " 2> /dev/null || code=256
397- if (( code >= 1 && code <= 31 )) ; then
408+ if (( code >= 1 && code <= 31 )) ; then
398409 printf ' \\u%04x' " $code "
399410 else
400411 printf ' %s' " $char "
@@ -519,7 +530,7 @@ resolve_template() {
519530 local repo_root=" $2 "
520531 local base=" $repo_root /.specify/templates"
521532
522- case " $template_name " in " " | * [!a-z0-9-]* ) return 1 ;; esac
533+ case " $template_name " in " " | * [!a-z0-9-]* ) return 1 ;; esac
523534
524535 # Priority 1: Project overrides
525536 local override=" $base /overrides/${template_name} .md"
@@ -566,7 +577,7 @@ except Exception:
566577 [ -f " $candidate " ] && echo " $candidate " && return 0
567578 candidate=" $presets_dir /$preset_id /${template_name} .md"
568579 [ -f " $candidate " ] && echo " $candidate " && return 0
569- done <<< " $sorted_presets"
580+ done <<< " $sorted_presets"
570581 fi
571582 # python3 succeeded but registry has no presets — nothing to search
572583 else
@@ -604,7 +615,7 @@ except Exception:
604615 local candidate=" $ext /templates/${template_name} .md"
605616 [ -f " $candidate " ] || candidate=" $ext /${template_name} .md"
606617 [ -f " $candidate " ] && echo " $candidate " && return 0
607- done <<< " $sorted_extensions"
618+ done <<< " $sorted_extensions"
608619 fi
609620
610621 # Priority 4: Core templates
@@ -628,7 +639,7 @@ resolve_template_content() {
628639 local repo_root=" $2 "
629640 local base=" $repo_root /.specify/templates"
630641
631- case " $template_name " in " " | * [!a-z0-9-]* ) return 1 ;; esac
642+ case " $template_name " in " " | * [!a-z0-9-]* ) return 1 ;; esac
632643
633644 # Collect all layers (highest priority first)
634645 local -a layer_paths=()
@@ -776,7 +787,7 @@ except Exception as exc:
776787 fi
777788 if [ -n " $result " ]; then
778789 local declaration
779- IFS=$' \t ' read -r declaration strategy manifest_file <<< " $result"
790+ IFS=$' \t ' read -r declaration strategy manifest_file <<< " $result"
780791 [ " $declaration " = " found" ] && manifest_declared=true
781792 strategy=$( printf ' %s' " $strategy " | tr ' [:upper:]' ' [:lower:]' )
782793 fi
@@ -786,7 +797,7 @@ except Exception as exc:
786797 local candidate=" "
787798 if [ -n " $manifest_file " ]; then
788799 case " $manifest_file " in
789- /* | * ../* ) manifest_file=" " ;;
800+ /* | * ../* ) manifest_file=" " ;;
790801 esac
791802 fi
792803 if [ -n " $manifest_file " ]; then
@@ -809,7 +820,7 @@ except Exception as exc:
809820 break
810821 fi
811822 fi
812- done <<< " $sorted_presets"
823+ done <<< " $sorted_presets"
813824 fi
814825 fi
815826
@@ -831,7 +842,7 @@ except Exception as exc:
831842 effective_base_found=true
832843 break
833844 fi
834- done <<< " $sorted_extensions"
845+ done <<< " $sorted_extensions"
835846 fi
836847
837848 # Priority 4: Core templates (always "replace")
@@ -872,7 +883,7 @@ except Exception as exc:
872883 # to find the nearest replace layer. Only compose layers above that base.
873884 local base_idx=-1
874885 local i
875- for (( i = 0 ; i< count; i++ )) ; do
886+ for (( i = 0 ; i < count; i++ )) ; do
876887 if [ " ${layer_strategies[$i]} " = " replace" ]; then
877888 base_idx=$i
878889 break
@@ -886,18 +897,28 @@ except Exception as exc:
886897
887898 # Read the base content; compose layers above the base (higher priority)
888899 local content
889- if ! content=$( cat " ${layer_paths[$base_idx]} " ; status=$? ; printf x; exit " $status " ) ; then
900+ if ! content=$(
901+ cat " ${layer_paths[$base_idx]} "
902+ status=$?
903+ printf x
904+ exit " $status "
905+ ) ; then
890906 echo " Error: failed to read template layer ${layer_paths[$base_idx]} " >&2
891907 return 2
892908 fi
893909 content=" ${content% x} "
894910
895- for (( i = base_idx- 1 ; i>= 0 ; i-- )) ; do
911+ for (( i = base_idx - 1 ; i >= 0 ; i-- )) ; do
896912 local path=" ${layer_paths[$i]} "
897913 local strat=" ${layer_strategies[$i]} "
898914 local layer_content
899915 # Preserve trailing newlines
900- if ! layer_content=$( cat " $path " ; status=$? ; printf x; exit " $status " ) ; then
916+ if ! layer_content=$(
917+ cat " $path "
918+ status=$?
919+ printf x
920+ exit " $status "
921+ ) ; then
901922 echo " Error: failed to read template layer $path " >&2
902923 return 2
903924 fi
@@ -906,17 +927,26 @@ except Exception as exc:
906927 case " $strat " in
907928 replace) content=" $layer_content " ;;
908929 prepend)
909- content=$( printf ' %s\n\n%s' " $layer_content " " $content " ; printf x)
930+ content=$(
931+ printf ' %s\n\n%s' " $layer_content " " $content "
932+ printf x
933+ )
910934 content=" ${content% x} "
911935 ;;
912936 append)
913- content=$( printf ' %s\n\n%s' " $content " " $layer_content " ; printf x)
937+ content=$(
938+ printf ' %s\n\n%s' " $content " " $layer_content "
939+ printf x
940+ )
914941 content=" ${content% x} "
915942 ;;
916943 wrap)
917944 case " $layer_content " in
918945 * ' {CORE_TEMPLATE}' * ) ;;
919- * ) echo " Error: wrap strategy missing {CORE_TEMPLATE} placeholder" >&2 ; return 2 ;;
946+ * )
947+ echo " Error: wrap strategy missing {CORE_TEMPLATE} placeholder" >&2
948+ return 2
949+ ;;
920950 esac
921951 # Consume the wrapper left to right instead of rewriting it in
922952 # place. Rewriting re-scanned the string just modified, so base
@@ -933,7 +963,10 @@ except Exception as exc:
933963 done
934964 content=" ${wrapped}${rest} "
935965 ;;
936- * ) echo " Error: unknown strategy '$strat '" >&2 ; return 2 ;;
966+ * )
967+ echo " Error: unknown strategy '$strat '" >&2
968+ return 2
969+ ;;
937970 esac
938971 done
939972
0 commit comments