Skip to content

Commit

Permalink
fix: Prevent unintended output when dotnet --version fails (#1054)
Browse files Browse the repository at this point in the history
`dotnet --version` prints all available versions when the version specified
in global.json is not installed. This causes the prompt to show this list in the version section
  • Loading branch information
bash committed Jul 28, 2021
1 parent bdb247d commit d18449a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sections/dotnet.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ spaceship_dotnet() {

# dotnet-cli automatically handles SDK pinning (specified in a global.json file)
# therefore, this already returns the expected version for the current directory
local dotnet_version=$(dotnet --version 2>/dev/null)
local dotnet_version # separate declaration so we have access to the exit code
dotnet_version=$(dotnet --version 2>/dev/null)

# `dotnet --version` exits with a non-zero exit code
# when the version defined in global.json is not installed.
[[ $? -eq 0 ]] || return

spaceship::section \
"$SPACESHIP_DOTNET_COLOR" \
Expand Down

0 comments on commit d18449a

Please sign in to comment.