Created
July 2, 2015 13:56
-
-
Save kbinani/a350def4862bc6550a37 to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
platform='Macintosh; ' | |
os_cpu=$(sw_vers 2>/dev/null | grep ProductVersion | sed 's/^ProductVersion:.\(.*\)/\1/g' | tr . _) | |
TMP=$(mktemp -t tmp) | |
trap "rm $TMP" EXIT | |
curl https://chromium.googlesource.com/chromium/src/+/master/content/webkit_version.h.in 2>/dev/null | sed 's:</[^>]*>: :g' | sed 's:<[^>]*>: :g' > "$TMP" | |
WEBKIT_VERSION_MAJOR=$(cat "$TMP" | sed 's:^.*WEBKIT_VERSION_MAJOR[ ]*\([0-9]*\).*$:\1:g') | |
WEBKIT_VERSION_MINOR=$(cat "$TMP" | sed 's:^.*WEBKIT_VERSION_MINOR[ ]*\([0-9]*\).*$:\1:g') | |
curl https://chromium.googlesource.com/chromium/src.git/+/master/chrome/VERSION 2>/dev/null | sed 's:</[^>]*>: :g' | sed 's:<[^>]*>: :g' > "$TMP" | |
MAJOR=$(cat "$TMP" | sed 's:^.*MAJOR *= *\([0-9]*\).*$:\1:g') | |
MINOR=$(cat "$TMP" | sed 's:^.*MINOR *= *\([0-9]*\).*$:\1:g') | |
BUILD=$(cat "$TMP" | sed 's:^.*BUILD *= *\([0-9]*\).*$:\1:g') | |
PATCH=$(cat "$TMP" | sed 's:^.*PATCH *= *\([0-9]*\).*$:\1:g') | |
product=$(printf 'Chrome/%d.%d.%d.%d' $MAJOR $MINOR $BUILD $PATCH) | |
printf 'Mozilla/5.0 (Macintosh; Intel Mac OS X %s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d' "$os_cpu" "$WEBKIT_VERSION_MAJOR" "$WEBKIT_VERSION_MINOR" "$product" "$WEBKIT_VERSION_MAJOR" "$WEBKIT_VERSION_MINOR" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment