Cleanup previous PR
This commit is contained in:
parent
ee3632b85d
commit
2619db0e58
@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import Optional, Dict, List
|
from contextlib import suppress
|
||||||
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
from .options.types import Options
|
|
||||||
from .constants import shell_integration_dir
|
from .constants import shell_integration_dir
|
||||||
|
from .options.types import Options
|
||||||
from .utils import log_error, which
|
from .utils import log_error, which
|
||||||
|
|
||||||
|
|
||||||
@ -37,13 +38,11 @@ def is_new_zsh_install(env: Dict[str, str], zdotdir: Optional[str]) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_zsh_zdotdir_from_gloabl_zshenv(env: Dict[str, str], argv: List[str]) -> Optional[str]:
|
def get_zsh_zdotdir_from_global_zshenv(env: Dict[str, str], argv: List[str]) -> Optional[str]:
|
||||||
exe = which(argv[0], only_system=True) or 'zsh'
|
exe = which(argv[0], only_system=True) or 'zsh'
|
||||||
try:
|
with suppress(Exception):
|
||||||
zdotdir = subprocess.check_output([exe, '--norcs', '--interactive', '-c', 'echo -n $ZDOTDIR'], env=env).decode('utf-8')
|
return subprocess.check_output([exe, '--norcs', '--interactive', '-c', 'echo -n $ZDOTDIR'], env=env).decode('utf-8')
|
||||||
except Exception:
|
return None
|
||||||
zdotdir = None
|
|
||||||
return zdotdir
|
|
||||||
|
|
||||||
|
|
||||||
def setup_zsh_env(env: Dict[str, str], argv: List[str]) -> None:
|
def setup_zsh_env(env: Dict[str, str], argv: List[str]) -> None:
|
||||||
@ -51,7 +50,7 @@ def setup_zsh_env(env: Dict[str, str], argv: List[str]) -> None:
|
|||||||
if is_new_zsh_install(env, zdotdir):
|
if is_new_zsh_install(env, zdotdir):
|
||||||
if zdotdir is None:
|
if zdotdir is None:
|
||||||
# Try to get ZDOTDIR from /etc/zshenv, when all startup files are not present
|
# Try to get ZDOTDIR from /etc/zshenv, when all startup files are not present
|
||||||
zdotdir = get_zsh_zdotdir_from_gloabl_zshenv(env, argv)
|
zdotdir = get_zsh_zdotdir_from_global_zshenv(env, argv)
|
||||||
if zdotdir is None or is_new_zsh_install(env, zdotdir):
|
if zdotdir is None or is_new_zsh_install(env, zdotdir):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user