Skip to content

Commit

Permalink
Allow env.sh to accept additional env var names (#3339)
Browse files Browse the repository at this point in the history
The hard-coded list is not necessarily enough. This allows the caller
to specify additional environment variables to write to .env.

Co-authored-by: Konstantin Tyukalov <52399739+KonstantinTyukalov@users.noreply.github.com>
Co-authored-by: Kirill Ivlev <102740624+kirill-ivlev@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 12, 2022
1 parent 6d0bf0d commit 27e3d4e
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/Misc/layoutroot/env.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

varCheckList=(
'LANG'
'JAVA_HOME'
'ANT_HOME'
'M2_HOME'
'ANDROID_HOME'
'GRADLE_HOME'
'NVM_BIN'
'LANG'
'JAVA_HOME'
'ANT_HOME'
'M2_HOME'
'ANDROID_HOME'
'GRADLE_HOME'
'NVM_BIN'
'NVM_PATH'
'VSTS_HTTP_PROXY'
'VSTS_HTTP_PROXY_USERNAME'
Expand All @@ -17,6 +17,16 @@ varCheckList=(
'AGENT_TOOLSDIRECTORY'
)

# Allows the caller to specify additional vars on the commandline, for example:
# ./env.sh DOTNET_SYSTEM_GLOBALIZATION_INVARIANT DOTNET_ROOT
for arg in "$@"
do
if [[ ! " ${varCheckList[@]} " =~ " ${arg} " ]]; then
varCheckList+=($arg)
fi
done


envContents=""

if [ -f ".env" ]; then
Expand All @@ -34,7 +44,7 @@ function writeVar()
if [ ! -z "${!checkVar}" ]; then
echo "${checkVar}=${!checkVar}">>.env
fi
fi
fi
}

echo $PATH>.path
Expand Down

0 comments on commit 27e3d4e

Please sign in to comment.