mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-07 01:40:58 +01:00
commit
219034f167
3 changed files with 41 additions and 1 deletions
16
news/fssup.rst
Normal file
16
news/fssup.rst
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
**Added:**
|
||||||
|
|
||||||
|
* New environment variable ``$FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE``
|
||||||
|
enables the removal of skipping foreign alias messages.
|
||||||
|
* New ``--suppress-skip-message`` command line option for skipping
|
||||||
|
foreign alias messages when sourcing foreign shells.
|
||||||
|
|
||||||
|
**Changed:** None
|
||||||
|
|
||||||
|
**Deprecated:** None
|
||||||
|
|
||||||
|
**Removed:** None
|
||||||
|
|
||||||
|
**Fixed:** None
|
||||||
|
|
||||||
|
**Security:** None
|
|
@ -260,6 +260,13 @@ def _SOURCE_FOREIGN_PARSER():
|
||||||
help="flag for whether or not sourced aliases should "
|
help="flag for whether or not sourced aliases should "
|
||||||
"replace the current xonsh aliases.",
|
"replace the current xonsh aliases.",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--suppress-skip-message",
|
||||||
|
default=None,
|
||||||
|
action="store_true",
|
||||||
|
dest="suppress_skip_message",
|
||||||
|
help="flag for whether or not skip messages should be suppressed.",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--show",
|
"--show",
|
||||||
default=False,
|
default=False,
|
||||||
|
@ -280,7 +287,13 @@ def _SOURCE_FOREIGN_PARSER():
|
||||||
|
|
||||||
def source_foreign(args, stdin=None, stdout=None, stderr=None):
|
def source_foreign(args, stdin=None, stdout=None, stderr=None):
|
||||||
"""Sources a file written in a foreign shell language."""
|
"""Sources a file written in a foreign shell language."""
|
||||||
|
env = builtins.__xonsh_env__
|
||||||
ns = _SOURCE_FOREIGN_PARSER.parse_args(args)
|
ns = _SOURCE_FOREIGN_PARSER.parse_args(args)
|
||||||
|
ns.suppress_skip_message = (
|
||||||
|
env.get("FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE")
|
||||||
|
if ns.suppress_skip_message is None
|
||||||
|
else ns.suppress_skip_message
|
||||||
|
)
|
||||||
if ns.prevcmd is not None:
|
if ns.prevcmd is not None:
|
||||||
pass # don't change prevcmd if given explicitly
|
pass # don't change prevcmd if given explicitly
|
||||||
elif os.path.isfile(ns.files_or_code[0]):
|
elif os.path.isfile(ns.files_or_code[0]):
|
||||||
|
@ -315,7 +328,6 @@ def source_foreign(args, stdin=None, stdout=None, stderr=None):
|
||||||
msg += "xonsh: error: Possible reasons: File not found or syntax error\n"
|
msg += "xonsh: error: Possible reasons: File not found or syntax error\n"
|
||||||
return (None, msg, 1)
|
return (None, msg, 1)
|
||||||
# apply results
|
# apply results
|
||||||
env = builtins.__xonsh_env__
|
|
||||||
denv = env.detype()
|
denv = env.detype()
|
||||||
for k, v in fsenv.items():
|
for k, v in fsenv.items():
|
||||||
if k in denv and v == denv[k]:
|
if k in denv and v == denv[k]:
|
||||||
|
@ -332,11 +344,15 @@ def source_foreign(args, stdin=None, stdout=None, stderr=None):
|
||||||
continue # no change from original
|
continue # no change from original
|
||||||
elif ns.overwrite_aliases or k not in baliases:
|
elif ns.overwrite_aliases or k not in baliases:
|
||||||
baliases[k] = v
|
baliases[k] = v
|
||||||
|
elif ns.suppress_skip_message:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
msg = (
|
msg = (
|
||||||
"Skipping application of {0!r} alias from {1!r} "
|
"Skipping application of {0!r} alias from {1!r} "
|
||||||
"since it shares a name with an existing xonsh alias. "
|
"since it shares a name with an existing xonsh alias. "
|
||||||
'Use "--overwrite-alias" option to apply it anyway.'
|
'Use "--overwrite-alias" option to apply it anyway.'
|
||||||
|
'You may prevent this message with "--suppress-skip-message" or '
|
||||||
|
'"$FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE = True".'
|
||||||
)
|
)
|
||||||
print(msg.format(k, ns.shell), file=stderr)
|
print(msg.format(k, ns.shell), file=stderr)
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,7 @@ def DEFAULT_ENSURERS():
|
||||||
"DYNAMIC_CWD_ELISION_CHAR": (is_string, ensure_string, ensure_string),
|
"DYNAMIC_CWD_ELISION_CHAR": (is_string, ensure_string, ensure_string),
|
||||||
"EXPAND_ENV_VARS": (is_bool, to_bool, bool_to_str),
|
"EXPAND_ENV_VARS": (is_bool, to_bool, bool_to_str),
|
||||||
"FORCE_POSIX_PATHS": (is_bool, to_bool, bool_to_str),
|
"FORCE_POSIX_PATHS": (is_bool, to_bool, bool_to_str),
|
||||||
|
"FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE": (is_bool, to_bool, bool_to_str),
|
||||||
"FOREIGN_ALIASES_OVERRIDE": (is_bool, to_bool, bool_to_str),
|
"FOREIGN_ALIASES_OVERRIDE": (is_bool, to_bool, bool_to_str),
|
||||||
"FUZZY_PATH_COMPLETION": (is_bool, to_bool, bool_to_str),
|
"FUZZY_PATH_COMPLETION": (is_bool, to_bool, bool_to_str),
|
||||||
"GLOB_SORTED": (is_bool, to_bool, bool_to_str),
|
"GLOB_SORTED": (is_bool, to_bool, bool_to_str),
|
||||||
|
@ -360,6 +361,7 @@ def DEFAULT_VALUES():
|
||||||
"DYNAMIC_CWD_ELISION_CHAR": "",
|
"DYNAMIC_CWD_ELISION_CHAR": "",
|
||||||
"EXPAND_ENV_VARS": True,
|
"EXPAND_ENV_VARS": True,
|
||||||
"FORCE_POSIX_PATHS": False,
|
"FORCE_POSIX_PATHS": False,
|
||||||
|
"FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE": False,
|
||||||
"FOREIGN_ALIASES_OVERRIDE": False,
|
"FOREIGN_ALIASES_OVERRIDE": False,
|
||||||
"PROMPT_FIELDS": dict(prompt.PROMPT_FIELDS),
|
"PROMPT_FIELDS": dict(prompt.PROMPT_FIELDS),
|
||||||
"FUZZY_PATH_COMPLETION": True,
|
"FUZZY_PATH_COMPLETION": True,
|
||||||
|
@ -570,6 +572,12 @@ def DEFAULT_DOCS():
|
||||||
"completion if set to anything truthy.",
|
"completion if set to anything truthy.",
|
||||||
configurable=ON_WINDOWS,
|
configurable=ON_WINDOWS,
|
||||||
),
|
),
|
||||||
|
"FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE": VarDocs(
|
||||||
|
"Whether or not foreign aliases should suppress the message "
|
||||||
|
"that informs the user when a foreign alias has been skipped "
|
||||||
|
"because it already exists in xonsh.",
|
||||||
|
configurable=True,
|
||||||
|
),
|
||||||
"FOREIGN_ALIASES_OVERRIDE": VarDocs(
|
"FOREIGN_ALIASES_OVERRIDE": VarDocs(
|
||||||
"Whether or not foreign aliases should override xonsh aliases "
|
"Whether or not foreign aliases should override xonsh aliases "
|
||||||
"with the same name. Note that setting of this must happen in the "
|
"with the same name. Note that setting of this must happen in the "
|
||||||
|
|
Loading…
Add table
Reference in a new issue