• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3pkgs=(
4  "com.apple.pkg.DeveloperToolsCLILeo" # standalone
5  "com.apple.pkg.DeveloperToolsCLI"    # from XCode
6  "com.apple.pkg.CLTools_Executables"  # Mavericks
7)
8
9for pkg in "${pkgs[@]}"; do
10  output=$(/usr/sbin/pkgutil --pkg-info "$pkg" 2>/dev/null)
11  if [ "$output" ]; then
12    version=$(echo "$output" | grep 'version' | cut -d' ' -f2)
13    break
14  fi
15done
16
17if [ "$version" ]; then
18  echo "Command Line Tools version: $version"
19else
20  echo >&2 'Command Line Tools not found'
21fi
22