force color in subshell if not SPACK_COLOR (#40782)

This commit is contained in:
Harmen Stoppels 2023-10-31 22:27:00 +01:00 committed by GitHub
parent 58e5315089
commit 343ed8a3fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -98,7 +98,7 @@ _spack_shell_wrapper() {
if [ "$_sp_arg" = "-h" ] || [ "$_sp_arg" = "--help" ]; then if [ "$_sp_arg" = "-h" ] || [ "$_sp_arg" = "--help" ]; then
command spack cd -h command spack cd -h
else else
LOC="$(spack location $_sp_arg "$@")" LOC="$(SPACK_COLOR="${SPACK_COLOR:-always}" spack location $_sp_arg "$@")"
if [ -d "$LOC" ] ; then if [ -d "$LOC" ] ; then
cd "$LOC" cd "$LOC"
else else
@ -136,7 +136,7 @@ _spack_shell_wrapper() {
command spack env activate "$@" command spack env activate "$@"
else else
# Actual call to activate: source the output. # Actual call to activate: source the output.
stdout="$(command spack $_sp_flags env activate --sh "$@")" || return stdout="$(SPACK_COLOR="${SPACK_COLOR:-always}" command spack $_sp_flags env activate --sh "$@")" || return
eval "$stdout" eval "$stdout"
fi fi
;; ;;
@ -158,7 +158,7 @@ _spack_shell_wrapper() {
command spack env deactivate -h command spack env deactivate -h
else else
# No args: source the output of the command. # No args: source the output of the command.
stdout="$(command spack $_sp_flags env deactivate --sh)" || return stdout="$(SPACK_COLOR="${SPACK_COLOR:-always}" command spack $_sp_flags env deactivate --sh)" || return
eval "$stdout" eval "$stdout"
fi fi
;; ;;
@ -186,7 +186,7 @@ _spack_shell_wrapper() {
# Args contain --sh, --csh, or -h/--help: just execute. # Args contain --sh, --csh, or -h/--help: just execute.
command spack $_sp_flags $_sp_subcommand "$@" command spack $_sp_flags $_sp_subcommand "$@"
else else
stdout="$(command spack $_sp_flags $_sp_subcommand --sh "$@")" || return stdout="$(SPACK_COLOR="${SPACK_COLOR:-always}" command spack $_sp_flags $_sp_subcommand --sh "$@")" || return
eval "$stdout" eval "$stdout"
fi fi
;; ;;