@@ -895,13 +895,7 @@ class CshActivator(_Activator):
895
895
set_var_tmpl = "set %s='%s'"
896
896
run_script_tmpl = 'source "%s"'
897
897
898
- hook_source_path = Path (
899
- CONDA_PACKAGE_ROOT ,
900
- "shell" ,
901
- "etc" ,
902
- "profile.d" ,
903
- "conda.csh" ,
904
- )
898
+ hook_source_path = None # see _hook_preamble
905
899
906
900
def _update_prompt (self , set_vars , conda_prompt_modifier ):
907
901
prompt = os .getenv ("prompt" , "" )
@@ -915,24 +909,31 @@ def _update_prompt(self, set_vars, conda_prompt_modifier):
915
909
)
916
910
917
911
def _hook_preamble (self ) -> str :
912
+ # TCSH/CSH removes newlines when doing command substitution (see `man tcsh`),
913
+ # source conda.csh directly and use line terminators to separate commands
914
+ hook_source_path = Path (
915
+ CONDA_PACKAGE_ROOT ,
916
+ "shell" ,
917
+ "etc" ,
918
+ "profile.d" ,
919
+ "conda.csh" ,
920
+ )
918
921
if on_win :
919
- return dedent (
920
- f"""
921
- setenv CONDA_EXE `cygpath { context .conda_exe } `
922
- setenv _CONDA_ROOT `cygpath { context .conda_prefix } `
923
- setenv _CONDA_EXE `cygpath { context .conda_exe } `
924
- setenv CONDA_PYTHON_EXE `cygpath { sys .executable } `
925
- """
926
- ).strip ()
922
+ return (
923
+ f"setenv CONDA_EXE \" `cygpath '{ context .conda_exe } '`\" ;\n "
924
+ f"setenv _CONDA_ROOT \" `cygpath '{ context .conda_prefix } '`\" ;\n "
925
+ f"setenv _CONDA_EXE \" `cygpath '{ context .conda_exe } '`\" ;\n "
926
+ f"setenv CONDA_PYTHON_EXE \" `cygpath '{ sys .executable } '`\" ;\n "
927
+ f"source \" `cygpath '{ hook_source_path } '`\" ;\n "
928
+ )
927
929
else :
928
- return dedent (
929
- f"""
930
- setenv CONDA_EXE "{ context .conda_exe } "
931
- setenv _CONDA_ROOT "{ context .conda_prefix } "
932
- setenv _CONDA_EXE "{ context .conda_exe } "
933
- setenv CONDA_PYTHON_EXE "{ sys .executable } "
934
- """
935
- ).strip ()
930
+ return (
931
+ f'setenv CONDA_EXE "{ context .conda_exe } ";\n '
932
+ f'setenv _CONDA_ROOT "{ context .conda_prefix } ";\n '
933
+ f'setenv _CONDA_EXE "{ context .conda_exe } ";\n '
934
+ f'setenv CONDA_PYTHON_EXE "{ sys .executable } ";\n '
935
+ f'source "{ hook_source_path } ";\n '
936
+ )
936
937
937
938
938
939
class XonshActivator (_Activator ):
0 commit comments