Skip to content

Commit e40d423

Browse files
authored
{Codespaces} Skip login in non-interactive shells (#32250)
1 parent e058975 commit e40d423

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

.devcontainer/init.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ source .venv/bin/activate
44
# Logout default account
55
export GITHUB_TOKEN=
66

7-
# Check `repo` scope exists or not
8-
if gh auth status -a 2>/dev/null | grep "Token scopes: " | grep -q "repo"; then
9-
echo "You now have access to GitHub."
10-
else
11-
gh auth login -p https -w
7+
if [[ $- == *i* ]]; then # Interactive shell only
8+
# Check `repo` scope exists or not
9+
if gh auth status -a 2>/dev/null | grep "Token scopes: " | grep -q "repo"; then
10+
echo "You now have access to GitHub."
11+
else
12+
gh auth login -p https -w
13+
fi
1214
fi
1315

1416
# Check `aaz-dev` is available or not

0 commit comments

Comments
 (0)