use new oidc-add --loaded option
@@ -142,10 +142,10 @@ fi
cat $INITSCRIPT
# Add given accounts if they're not already loaded.
+LOADED="`oidc-add --loaded 2>/dev/null`"
+LOADED=" `echo $LOADED` "
for ACCOUNT; do
- # Would prefer an option to oidc-agent or oidc-add to find out if an
- # account is loaded, but for now find out by trying to get a token.
- if oidc-token $ACCOUNT 2>&1|grep -q Error:; then
+ if [[ "$LOADED" != *" $ACCOUNT "* ]]; then
# Account not already loaded, so add it.
# Send all messages to stderr and also pipe to grep to look for error
if oidc-add $ACCOUNT 2>&1|tee /dev/fd/2|grep -q Error:; then
