Last active
March 18, 2019 17:44
-
-
Save homebysix/501a3bc5144b77aecc0c to your computer and use it in GitHub Desktop.
Casper extension attribute that collects the version of Git installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### | |
# | |
# Name: git_version.sh | |
# Description: Casper extension attribute that displays the version of Git. | |
# Excludes /usr/bin/git in order to prevent Xcode install prompt. | |
# Author: Elliot Jordan <[email protected]> | |
# Created: 2014-12-19 | |
# Last Modified: 2014-12-22 | |
# Version: 1.1.1 | |
# | |
### | |
CURRENT_USER=$(/usr/bin/stat -f%Su /dev/console) | |
CURRENT_PATH=$(/usr/bin/su "$CURRENT_USER" -c "/usr/bin/env | /usr/bin/grep PATH= | /usr/bin/colrm 1 5 | sed 's/\/usr\/bin://g'") | |
RESULT="" | |
old=$IFS | |
IFS=: | |
for p in $CURRENT_PATH; do | |
GIT_VERSION="$($p/git --version 2> /dev/null)" | |
if [[ $? == 0 ]]; then | |
RESULT+="$p $GIT_VERSION\n" | |
fi | |
done | |
IFS=$old | |
/usr/bin/printf "<result>$RESULT</result>\n" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment