From 19fd56468fa5f27d4245ab1174973c62409157d3 Mon Sep 17 00:00:00 2001 From: Joe Horsnell Date: Mon, 1 Jul 2019 17:25:25 +0100 Subject: [PATCH 1/2] Gracefully handle missing USER env var Prompted by https://github.com/Homebrew/install/pull/213 --- Library/Homebrew/brew.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 364065b578..bf484258a9 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -4,6 +4,11 @@ then export LC_ALL="en_US.UTF-8" fi +# The USER env var is not guaranteed to be available, so fall back to id if not +# provided. We destructively set it in the environment to make it available to +# any sub-processes called. +export USER=${USER:-`id -un`} + # Where we store built products; a Cellar in HOMEBREW_PREFIX (often /usr/local # for bottles) unless there's already a Cellar in HOMEBREW_REPOSITORY. if [[ -d "$HOMEBREW_REPOSITORY/Cellar" ]] From 90f6e3988e234fca798a4141af8021ed3f9bfe48 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 3 Jul 2019 09:38:14 +0100 Subject: [PATCH 2/2] brew.sh: tweak USER comment. --- Library/Homebrew/brew.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index bf484258a9..2cfde1590f 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -4,9 +4,7 @@ then export LC_ALL="en_US.UTF-8" fi -# The USER env var is not guaranteed to be available, so fall back to id if not -# provided. We destructively set it in the environment to make it available to -# any sub-processes called. +# USER isn't always set so provide a fall back for `brew` and subprocesses. export USER=${USER:-`id -un`} # Where we store built products; a Cellar in HOMEBREW_PREFIX (often /usr/local