Skip to content

Commit

Permalink
⚡ Remove readarray for check
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbarton90 committed Apr 10, 2024
1 parent 7c46d5a commit 3e669ce
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gh-clean-notifications
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ check() {

current_gh_ver=$(gh --version | \
tail -n 1 | \
awk 'match($0, "\/v.*$"){print substr($0,RSTART+1,RLENGTH)}'
awk 'match($0, "\\/v.*$"){print substr($0,RSTART+1,RLENGTH)}'
)

if [ ${VERBOSE} -gt 0 ]; then
echo "Current gh cli version: ${current_gh_ver}"
fi

min_version=$(printf "%s\n%s" "${MIN_GH_VERSION}" "${current_gh_ver}" | \
sort --version-sort | \
sort -V | \
head -n 1
)
if [ "${min_version}" != "${MIN_GH_VERSION}" ]; then
Expand All @@ -92,13 +92,12 @@ check() {
grep -i "Token scopes" | \
awk '{ gsub(/\047/, "", $0); split($0,s,": "); gsub(/, /, "\n", s[2]); print s[2] }'
)
readarray -t scopes < <(echo "${scopes_str}")

org=0
notifications=0
repo=0

for scope in "${scopes[@]}"; do
while read -r scope; do
case "${scope}" in
repo)
repo=1;;
Expand All @@ -109,7 +108,7 @@ check() {
notifications)
notifications=1;;
esac
done
done < <(echo "${scopes_str}")

if [ ${VERBOSE} -gt 0 ]; then
echo "The scope check returns:"
Expand Down

0 comments on commit 3e669ce

Please sign in to comment.