Fix Shellcheck SC2089 and SC2090: Quotes in vars

SC2089: Quotes/backslashes will be treated literally. Use an array.

https://github.com/koalaman/shellcheck/wiki/SC2089

SC2090: Quotes/backslashes in this variable will not be respected.

https://github.com/koalaman/shellcheck/wiki/SC2090

Putting literal JSON in a variable mistakenly triggers these warnings.
Instead of adding ignore directives, this can be avoided by inlining the
JSON data into the curl invocation.

Since the variable is only used in this one location, inlining is fine.

Signed-off-by: Dan Callahan <danc@element.io>
This commit is contained in:
Dan Callahan 2021-10-21 23:38:29 +01:00
parent dfa6143133
commit 99e698d6ed
No known key found for this signature in database
GPG Key ID: 5FAD56482D9EB851

View File

@ -84,7 +84,9 @@ AUTH="Authorization: Bearer $TOKEN"
################################################################################################### ###################################################################################################
# finally start pruning the room: # finally start pruning the room:
################################################################################################### ###################################################################################################
POSTDATA='{"delete_local_events":"true"}' # this will really delete local events, so the messages in the room really disappear unless they are restored by remote federation # this will really delete local events, so the messages in the room really
# disappear unless they are restored by remote federation. This is because
# we pass {"delete_local_events":true} to the curl invocation below.
for ROOM in "${ROOMS_ARRAY[@]}"; do for ROOM in "${ROOMS_ARRAY[@]}"; do
echo "########################################### $(date) ################# " echo "########################################### $(date) ################# "
@ -104,7 +106,7 @@ for ROOM in "${ROOMS_ARRAY[@]}"; do
SLEEP=2 SLEEP=2
set -x set -x
# call purge # call purge
OUT=$(curl --header "$AUTH" -s -d $POSTDATA POST "$API_URL/admin/purge_history/$ROOM/$EVENT_ID") OUT=$(curl --header "$AUTH" -s -d '{"delete_local_events":true}' POST "$API_URL/admin/purge_history/$ROOM/$EVENT_ID")
PURGE_ID=$(echo "$OUT" |grep purge_id|cut -d'"' -f4 ) PURGE_ID=$(echo "$OUT" |grep purge_id|cut -d'"' -f4 )
if [ "$PURGE_ID" == "" ]; then if [ "$PURGE_ID" == "" ]; then
# probably the history purge is already in progress for $ROOM # probably the history purge is already in progress for $ROOM