More robust env.sh | Fix conda activate if in subshell
This commit is contained in:
@@ -53,3 +53,27 @@ function restore_bash_options
|
||||
{
|
||||
set +vx; eval "$OLDSTATE"
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Wrapper around replace-content.py.
|
||||
# For a file ($1), write out text ($3) into it
|
||||
# replacing any area designated by $2.
|
||||
#######################################
|
||||
function replace_content
|
||||
{
|
||||
# On macOS, use GNU readlink from 'coreutils' package in Homebrew/MacPorts
|
||||
if [ "$(uname -s)" = "Darwin" ] ; then
|
||||
READLINK=greadlink
|
||||
else
|
||||
READLINK=readlink
|
||||
fi
|
||||
|
||||
# If BASH_SOURCE is undefined, we may be running under zsh, in that case
|
||||
# provide a zsh-compatible alternative
|
||||
DIR="$(dirname "$($READLINK -f "${BASH_SOURCE[0]:-${(%):-%x}}")")"
|
||||
file="$1"
|
||||
shift
|
||||
key="$1"
|
||||
shift
|
||||
$DIR/replace-content.py "$file" "$key" "$@"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user