Skip to content

Commit

Permalink
Fix SC2015
Browse files Browse the repository at this point in the history
Use full if-then-else
  • Loading branch information
oh2fih authored Mar 5, 2024
1 parent 0c24602 commit 7342c6c
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions securitytxt-signer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,25 @@ if ! [[ "$KEY" =~ ^0x[a-fA-F0-9]{8,40}$ ]]; then
else
KEY_INFO=$(gpg --list-secret-keys "$KEY" 2> >(sed $'s,.*,\e[33m&\e[m,'>&2))

KEY_EXPIRES=$(
echo "$KEY_INFO" \
| grep "sec" \
| grep -Eo 'expires:\ [0-9\-]+' \
| awk '{ print $2}' \
| ( (( IS_MAC )) && date -Iseconds -u || date -Iseconds -u -f - ) \
| sed -e 's/+00:00$/Z/'
)
if (( IS_MAC )); then
KEY_EXPIRES=$(
echo "$KEY_INFO" \
| grep "sec" \
| grep -Eo 'expires:\ [0-9\-]+' \
| awk '{ print $2}' \
| date -Iseconds -u \
| sed -e 's/+00:00$/Z/'
)
else
KEY_EXPIRES=$(
echo "$KEY_INFO" \
| grep "sec" \
| grep -Eo 'expires:\ [0-9\-]+' \
| awk '{ print $2}' \
| date -Iseconds -u -f - \
| sed -e 's/+00:00$/Z/'
)
fi
echo

if [[ "$KEY_EXPIRES" = "" ]]; then
Expand Down

0 comments on commit 7342c6c

Please sign in to comment.