Skip to content

Commit 806a8ae

Browse files
authored
Merge pull request #1046 from kalfeher/bugfix/fix-bash-support
Fix script to run in bash
2 parents def93e5 + a873433 commit 806a8ae

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

scripts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The script [checklist_graph.sh](./checklist_graph.sh) can do the automated graph
1818
You can download the script in any environment that supports Azure CLI, such as the [Azure Cloud Shell](https://shell.azure.com). In order to download the script and prepare it for execution you can run this command:
1919

2020
```Shell
21-
wget quiet output-document ./checklist_graph.sh https://raw.githubusercontent.com/Azure/review-checklists/main/scripts/checklist_graph.sh
21+
wget -quiet -output-document=./checklist_graph.sh https://raw.githubusercontent.com/Azure/review-checklists/main/scripts/checklist_graph.sh
2222
chmod +xr ./checklist_graph.sh
2323
```
2424

scripts/checklist_graph.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/zsh
1+
#!/usr/bin/env bash
22

33
##################################################################################################
44
# This script downloads the latest JSON checklist in https://github.com/Azure/review-checklists
@@ -197,20 +197,20 @@ fi
197197
if [[ "$debug" == "yes" ]]; then echo "DEBUG: Extracting information from JSON..."; fi
198198
if [[ -n "$category_name" ]]
199199
then
200-
graph_query_list=$(print -r "$checklist_json" | jq -r '.items[] | select(.category=="'$category_name'") | .graph')
201-
category_list=$(print -r "$checklist_json" | jq -r '.items[] | select(.category=="'$category_name'") | .category')
202-
text_list=$(print -r "$checklist_json" | jq -r '.items[] | select(.category=="'$category_name'") | .text')
203-
guid_list=$(print -r "$checklist_json" | jq -r '.items[] | select(.category=="'$category_name'") | .guid')
200+
graph_query_list=$(echo -E "$checklist_json" | jq -r '.items[] | select(.category=="'$category_name'") | .graph')
201+
category_list=$(echo -E "$checklist_json" | jq -r '.items[] | select(.category=="'$category_name'") | .category')
202+
text_list=$(echo -E "$checklist_json" | jq -r '.items[] | select(.category=="'$category_name'") | .text')
203+
guid_list=$(echo -E "$checklist_json" | jq -r '.items[] | select(.category=="'$category_name'") | .guid')
204204
if [[ -z "$text_list" ]]; then
205205
echo "ERROR: error processing JSON file, please verify the syntax"
206206
exit
207207
fi
208208
if [[ "$debug" == "yes" ]]; then echo "DEBUG: $(echo $text_list | wc -l) tests found in the checklist for category ${category_name}."; fi
209209
else
210-
graph_query_list=$(print -r "$checklist_json" | jq -r '.items[] | .graph')
211-
category_list=$(print -r "$checklist_json" | jq -r '.items[] | .category')
212-
text_list=$(print -r "$checklist_json" | jq -r '.items[] | .text')
213-
guid_list=$(print -r "$checklist_json" | jq -r '.items[] | .guid')
210+
graph_query_list=$(echo -E "$checklist_json" | jq -r '.items[] | .graph')
211+
category_list=$(echo -E "$checklist_json" | jq -r '.items[] | .category')
212+
text_list=$(echo -E "$checklist_json" | jq -r '.items[] | .text')
213+
guid_list=$(echo -E "$checklist_json" | jq -r '.items[] | .guid')
214214
if [[ -z "$text_list" ]]; then
215215
echo "ERROR: error processing JSON file, please verify the syntax"
216216
exit
@@ -284,7 +284,7 @@ while IFS= read -r graph_query; do
284284
graph_query=$(echo "$graph_query") # Fix for backslashes
285285
if [[ "$debug" == "yes" ]]; then echo "DEBUG: Running query \"$graph_query\"..."; fi
286286
# The query should return one line per result. Fields ID and Compliant and mandatory
287-
query_result=$(az graph query -q "$graph_query" ${(z)mg_option} -o tsv 2>$error_file --query 'data[].[id,compliant]' | sort -u)
287+
query_result=$(az graph query -q "$graph_query" ${mg_option} -o tsv 2>$error_file --query 'data[].[id,compliant]' | sort -u)
288288
rm $error_file 2>/dev/null; touch $error_file
289289
while IFS= read -r result
290290
do

0 commit comments

Comments
 (0)