Xonfig: show sensitive env variables that could affect the shell behavior. (#5374)

* wip

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added XONSH_SUBPROC_OUTPUT_FORMAT

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Andy Kipp 2024-05-02 19:16:22 +02:00 committed by GitHub
parent 4906ba8598
commit c4c7d1cbd7
Failed to generate hash of commit
2 changed files with 38 additions and 0 deletions

23
news/xonfig_env.rst Normal file
View file

@ -0,0 +1,23 @@
**Added:**
* Xonfig: show sensitive env variables that could affect the shell behavior.
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* <news item>
**Security:**
* <news item>

View file

@ -561,6 +561,21 @@ def _info(
data.extend([("xontrib", xontribs_loaded())])
data.extend([("RC file", XSH.rc_files)])
# Show sensitive env variables that could affect the shell behavior.
envs = {
"UPDATE_OS_ENVIRON": None,
"XONSH_CAPTURE_ALWAYS": None,
"XONSH_SUBPROC_OUTPUT_FORMAT": None,
"THREAD_SUBPROCS": None,
"ENABLE_ASYNC_PROMPT": True,
"ENABLE_COMMANDS_CACHE": False,
"XONSH_CACHE_EVERYTHING": True,
"XONSH_CACHE_SCRIPTS": None,
}
for e, show_if in envs.items():
if (val := XSH.env.get(e)) is not None and (show_if is None or val == show_if):
data.extend([(e, val)])
formatter = _xonfig_format_json if to_json else _xonfig_format_human
s = formatter(data)
return s