Some tests and changelog

This commit is contained in:
Anthony Scopatz 2018-12-10 08:17:22 -05:00
parent 61fe13bc77
commit a8d63110f3
4 changed files with 54 additions and 7 deletions

52
news/execaliasbash.rst Normal file
View file

@ -0,0 +1,52 @@
**Added:**
* Aliases from foreign shells (e.g. Bash) that are more than single expressions,
or contain sub-shell executions, are now evaluated and run in the foreign shell.
Previously, xonsh would attempt to translate the alias from sh-lang into
xonsh. These restrictions have been removed. For example, the following now
works:
.. code-block:: sh
$ source-bash 'alias eee="echo aaa \$(echo b)"'
$ eee
aaa b
* New ``ForeignShellBaseAlias``, ``ForeignShellFunctionAlias``, and
``ForeignShellExecAlias`` classes have been added which manage foreign shell
alias execution.
**Changed:**
* String aliases will now first be checked to see if they contain sub-expressions
that require evaluations, such as ``@(expr)``, ``$[cmd]``, etc. If they do,
then an ``ExecAlias`` will be constructed, rather than a simple list-of-strs
substitutiuon alias being used. For example:
.. code-block:: sh
$ aliases['uuu'] = "echo ccc $(echo ddd)"
$ aliases['uuu']
ExecAlias('echo ccc $(echo ddd)\n', filename='<exec-alias:uuu>')
$ uuu
ccc ddd
* The ``parse_aliases()`` function now requires the shell name.
* ``ForeignShellFunctionAlias`` now inherits from ``ForeignShellBaseAlias``
rather than ``object``.
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* <news item>
**Security:**
* <news item>

View file

@ -1,11 +1,6 @@
#!/usr/bin/env xonsh #!/usr/bin/env xonsh
$RAISE_SUBPROC_ERROR = True $RAISE_SUBPROC_ERROR = True
if 'TF_BUILD' in ${...}:
print('TF_BUILD', repr($TF_BUILD))
else:
print('TF_BUILD not found')
run_separately = [ run_separately = [
'tests/test_ptk_highlight.py', 'tests/test_ptk_highlight.py',
] ]

View file

@ -64,7 +64,7 @@ def test_parse_aliases():
"__XONSH_ALIAS_END__\n" "__XONSH_ALIAS_END__\n"
"more filth" "more filth"
) )
obs = parse_aliases(s) obs = parse_aliases(s, 'bash')
assert exp == obs assert exp == obs

View file

@ -418,7 +418,7 @@ def parse_funcs(s, shell, sourcer=None, extra_args=()):
if not os.path.isabs(filename): if not os.path.isabs(filename):
filename = os.path.abspath(filename) filename = os.path.abspath(filename)
wrapper = ForeignShellFunctionAlias( wrapper = ForeignShellFunctionAlias(
name=funcname, funcname=funcname,
shell=shell, shell=shell,
sourcer=sourcer, sourcer=sourcer,
filename=filename, filename=filename,