From 8e231d8ef509e4e1c4c9d034354db4187ad05939 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 7 Oct 2016 18:02:38 +0100 Subject: [PATCH] brew.sh: improve user agent with no git repo. `Homebrew/>1.0.0 (no git repository) (Macintosh; Intel macOS 10.7.5)...) reads pretty weirdly in a user agent and I've had complaints that `>` may be an invalid character in some cases. --- Library/Homebrew/brew.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 8ffee44b3f..114259c7e7 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -1,7 +1,9 @@ HOMEBREW_VERSION="$(git -C "$HOMEBREW_REPOSITORY" describe --tags --dirty 2>/dev/null)" +HOMEBREW_USER_AGENT_VERSION="$HOMEBREW_VERSION" if [[ -z "$HOMEBREW_VERSION" ]] then HOMEBREW_VERSION=">1.0.0 (no git repository)" + HOMEBREW_USER_AGENT_VERSION="1.X.Y" fi # A depth of 1 means this command was directly invoked by a user. @@ -109,7 +111,7 @@ else [[ -n "$HOMEBREW_LINUX" ]] && HOMEBREW_OS_VERSION="$(lsb_release -sd 2>/dev/null)" : "${HOMEBREW_OS_VERSION:=$(uname -r)}" fi -HOMEBREW_USER_AGENT="$HOMEBREW_PRODUCT/$HOMEBREW_VERSION ($HOMEBREW_SYSTEM; $HOMEBREW_PROCESSOR $HOMEBREW_OS_VERSION)" +HOMEBREW_USER_AGENT="$HOMEBREW_PRODUCT/$HOMEBREW_USER_AGENT_VERSION ($HOMEBREW_SYSTEM; $HOMEBREW_PROCESSOR $HOMEBREW_OS_VERSION)" HOMEBREW_CURL_VERSION="$("$HOMEBREW_CURL" --version 2>/dev/null | head -n1 | /usr/bin/awk '{print $1"/"$2}')" HOMEBREW_USER_AGENT_CURL="$HOMEBREW_USER_AGENT $HOMEBREW_CURL_VERSION"