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_ {
70
70
# -h .totalHourlyCost > 0.1
71
71
# --hook-config=.currency == "USD"
72
72
first_char=${check: 0: 1}
73
- last_char=${check: - 1}
73
+ last_char=${check: $(( ${ # check} - 1)) : 1}
74
74
if [ " $first_char " == " $last_char " ] && {
75
75
[ " $first_char " == ' "' ] || [ " $first_char " == " '" ]
76
76
}; then
77
- check=" ${check: 1:- 1 } "
77
+ check=" ${check: 1: $(( ${ # check} - 2)) } "
78
78
fi
79
79
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
+
81
86
# Get the very last operator, that is used in comparison inside `jq` query.
82
87
# From the example below we need to pick the `>` which is in between `add` and `1000`,
83
88
# but not the `!=`, which goes earlier in the `jq` expression
84
89
# [.projects[].diff.totalMonthlyCost | select (.!=null) | tonumber] | add > 1000
85
- operation=${operations[-1 ]}
90
+ operation=${operations[$((${#operations[@]} - 1)) ]}
86
91
87
92
IFS=" $operation " read -r -a jq_check <<< " $check"
88
93
real_value=" $( jq " ${jq_check[0]} " <<< " $RESULTS" ) "
You can’t perform that action at this time.
0 commit comments