File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -70,19 +70,24 @@ function infracost_breakdown_ {
7070 # -h .totalHourlyCost > 0.1
7171 # --hook-config=.currency == "USD"
7272 first_char=${check: 0: 1}
73- last_char=${check: - 1}
73+ last_char=${check: $(( ${ # check} - 1)) : 1}
7474 if [ " $first_char " == " $last_char " ] && {
7575 [ " $first_char " == ' "' ] || [ " $first_char " == " '" ]
7676 }; then
77- check=" ${check: 1:- 1 } "
77+ check=" ${check: 1: $(( ${ # check} - 2)) } "
7878 fi
7979
80- mapfile -t operations < <( echo " $check " | grep -oE ' [!<>=]{1,2}' )
80+ # Replace mapfile with while read loop for bash 3.2 compatibility
81+ operations=()
82+ while IFS= read -r line; do
83+ operations+=(" $line " )
84+ done < <( echo " $check " | grep -oE ' [!<>=]{1,2}' )
85+
8186 # Get the very last operator, that is used in comparison inside `jq` query.
8287 # From the example below we need to pick the `>` which is in between `add` and `1000`,
8388 # but not the `!=`, which goes earlier in the `jq` expression
8489 # [.projects[].diff.totalMonthlyCost | select (.!=null) | tonumber] | add > 1000
85- operation=${operations[-1 ]}
90+ operation=${operations[$((${#operations[@]} - 1)) ]}
8691
8792 IFS=" $operation " read -r -a jq_check <<< " $check"
8893 real_value=" $( jq " ${jq_check[0]} " <<< " $RESULTS" ) "
You can’t perform that action at this time.
0 commit comments