Skip to content

Commit

Permalink
fix: Hardened the Docker version checking logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufkandemir committed Jul 13, 2020
1 parent d4642e4 commit e075f08
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sections/docker.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ spaceship_docker() {
[[ "$compose_exists" == true || -f Dockerfile || -f docker-compose.yml || -f /.dockerenv || -n $docker_context ]] || return

# if docker daemon isn't running you'll get an error saying it can't connect
local docker_version=$(docker version -f "{{.Server.Version}}" 2>/dev/null)
[[ -z $docker_version ]] && return
# Note: Declaration and assignment is separated for correctly getting the exit code
local docker_version
docker_version=$(docker version -f "{{.Server.Version}}" 2>/dev/null)
[[ $? -ne 0 || -z $docker_version ]] && return

[[ $SPACESHIP_DOCKER_VERBOSE == false ]] && docker_version=${docker_version%-*}

Expand Down

0 comments on commit e075f08

Please sign in to comment.