Skip to content

Commit b2a7d24

Browse files
authored
[Release Tooling] Fix .bash_profile warning for when no .bash_profile exists (#12158)
1 parent d9bcd14 commit b2a7d24

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ReleaseTooling/Sources/Utils/ShellUtils.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,16 @@ public extension Shell {
6262
// Write the temporary script contents to the script's path. CocoaPods complains when LANG
6363
// isn't set in the environment, so explicitly set it here. The `/usr/local/git/current/bin`
6464
// is to allow the `sso` protocol if it's there.
65+
// The user's .bash_profile, if it exists, is sourced to modify the
66+
// shell's PATH with any configuration (e.g. adding Ruby to path)
67+
// that may be needed to run the given command.
6568
let contents = """
6669
export PATH="/usr/local/bin:/usr/local/git/current/bin:$PATH"
6770
export LANG="en_US.UTF-8"
68-
source ~/.bash_profile
71+
BASH_PROFILE_PATH="~/.bash_profile"
72+
if [ -f "$BASH_PROFILE_PATH" ]; then
73+
source $BASH_PROFILE_PATH
74+
fi
6975
\(command)
7076
"""
7177
try contents.write(to: scriptPath, atomically: true, encoding: .utf8)

0 commit comments

Comments
 (0)