Skip to content

Commit

Permalink
Fix shellcheck suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvs committed Apr 23, 2024
1 parent a276eb6 commit d2ea03e
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/oidc-tokensh/oidc-tokensh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ usage()
echo "command defaults to \$SHELL"
} >&2

if [ $# = 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "[${LINENO}] You ran: $0 $@"
usage
fi
# if [ $# = 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
# echo "[${LINENO}] You ran: $0 $*"
# # usage
# fi

OIDC_TOKEN_ARGS=""
CMND_ARGS=""
Expand Down Expand Up @@ -137,19 +137,15 @@ start_agent(){
echo "[${LINENO}] starting: >>oidc-agent -- /bin/bash -c "$0 --renewer ${ORIG_ARGS}"<<"
}
oidc-agent -- /bin/bash -c "$0 --renewer ${ORIG_ARGS}"

# old and working:
# echo "[${LINENO}] starting: >>oidc-agent -- /bin/bash -c $0 --renewer --oidc egi<<"
# oidc-agent -- /bin/bash -c "$0 --renewer --oidc egi"
}

start_token_renewer() {
# enable job control so background processes get their own process group
gettoken "Initial" 2
set -m
{
exec 3>&1 1>>$BEARER_TOKEN_FILE.log
exec 4>&2 2>>$BEARER_TOKEN_FILE.log
exec 3>&1 1>>"$BEARER_TOKEN_FILE.log"
exec 4>&2 2>>"$BEARER_TOKEN_FILE.log"
trap cleanup 0
# keep a copy of $PPID because it will change to 1 if parent dies
PARENTPID=$PPID
Expand Down Expand Up @@ -183,15 +179,15 @@ start_token_renewer() {

cleanup()
{
if kill -- -$BACKGROUND_PID 2>/dev/null; then
if kill -- -"$BACKGROUND_PID" 2>/dev/null; then
wait 2>/dev/null
rm -f "${BEARER_TOKEN_FILE}" "${BEARER_TOKEN_FILE}.log"
else
# echo >&2
exec 1>&3 3>&-
exec 2>&4 4>&-
echo -e "\n\nRenewal background process failed to renew Access Token, see $BEARER_TOKEN_FILE.log\n"
echo "Renewal background process failed, see $BEARER_TOKEN_FILE.log" >> ${BEARER_TOKEN_FILE}.log
echo "Renewal background process failed, see $BEARER_TOKEN_FILE.log" >> "${BEARER_TOKEN_FILE}.log"
exit 2
fi
}
Expand Down

0 comments on commit d2ea03e

Please sign in to comment.