summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Wassberg <jocar@sunet.se>2022-11-01 12:34:34 +0100
committerJohan Wassberg <jocar@sunet.se>2022-11-01 12:34:34 +0100
commitb430f924b0f17b148074ed1fcd95468c1bbd8106 (patch)
tree51f11ee52c5cf0792dc3aef48535dd15ea789510
parent85c2bacaeed7dce1b24742c26cf475da958120c8 (diff)
`shell-check` now runs quiet
-rwxr-xr-xscripts/remove_entity.sh29
1 files changed, 15 insertions, 14 deletions
diff --git a/scripts/remove_entity.sh b/scripts/remove_entity.sh
index 11bd6852..ae55a51e 100755
--- a/scripts/remove_entity.sh
+++ b/scripts/remove_entity.sh
@@ -14,54 +14,55 @@ fi
metadataurl=$1
if [ -s "${metadataurl}" ]; then
- entityidfn=$(basename $metadataurl)
+ entityidfn=$(basename "$metadataurl")
else
case $metadataurl in
[0-9][0-9]*)
url="https://metadata.swamid.se/?rawXML=${metadataurl}"
;;
https://metadata.swamid.se/?showEntity=*)
- url=$(echo "$metadataurl" | sed 's;showEntity;rawXML;')
+ #url=$(echo "$metadataurl" | sed 's;showEntity;rawXML;')
+ url=${metadataurl//showEntity/rawXML}
;;
esac
- metadata=`curl -L -m 5 -s -k -f "${url}"`
+ metadata=$(curl -L -m 5 -s -k -f "${url}")
[ -n "$metadata" ] || error "Failed to fetch metadata from $metadataurl"
- entityid=`echo "$metadata" | sed -n 's/.*entityID=['\''"]\([^"]*\)['\''"].*/\1/p'`
+ entityid=$(echo "$metadata" | sed -n 's/.*entityID=['\''"]\([^"]*\)['\''"].*/\1/p')
[ -n "$entityid" ] || error "Failed to find entityID in metadata"
- [ `echo "$entityid" | wc -l` = 1 ] || error "Multiple entityid:s found: `echo $entityid`"
+ [ "$(echo "$entityid" | wc -l | sed 's/ //g')" = "1" ] || error "Multiple entityid:s found: $entityid"
- entityidfn=`echo "$entityid" | sed 's;.*://;;' | sed 's/[^a-zwA-ZW0-9_.-]/-/g' | sed 's/$/.xml/'`
+ entityidfn=$(echo "$entityid" | sed 's;.*://;;' | sed 's/[^a-zwA-ZW0-9_.-]/-/g' | sed 's/$/.xml/')
[ -n "$entityidfn" ] || error "Failed to generate filename from entityid $entityid"
fi
file="swamid-2.0/$entityidfn"
if [ -r "$file" ]; then
echo "---------------------"
- grep "/$entityidfn" *.mxml sp-with-simplesign
+ grep "/$entityidfn" ./*.mxml sp-with-simplesign
echo "---------------------"
echo -n "OK to remove ? [Y/n]"
- read x
+ read -r x
case $x in
"Y"|"y"|"") ;;
*) exit 1 ;;
esac
echo
- if (grep -q $entityidfn sp-with-simplesign); then
+ if (grep -q "$entityidfn" sp-with-simplesign); then
sed -i.bak "/\/$entityidfn/d" sp-with-simplesign
if [ -f sp-with-simplesign.bak ]; then
rm sp-with-simplesign.bak
fi
fi
- git rm $file
+ git rm "$file"
- grep $file *.mxml | sed 's/\(.*\.mxml\): <xi:include href=".*"\/>/\1/' | while read mxmlfile ; do
- sed -i.bak "/\/$entityidfn/d" $mxmlfile
- if [ -f $mxmlfile.bak ]; then
- rm $mxmlfile.bak
+ grep "$file" ./*.mxml | sed 's/\(.*\.mxml\): <xi:include href=".*"\/>/\1/' | while read -r mxmlfile ; do
+ sed -i.bak "/\/$entityidfn/d" "$mxmlfile"
+ if [ -f "$mxmlfile".bak ]; then
+ rm "$mxmlfile".bak
fi
done
git diff