xonsh/docs/bash_to_xsh.rst

43 lines
1.5 KiB
Bash
Raw Normal View History

2016-02-04 22:37:45 -05:00
Bash to Xonsh Translation Guide
================================
2016-02-21 16:25:16 -05:00
As you have probably figured out by now, xonsh is not ``sh``-lang compliant.
2016-02-04 22:37:45 -05:00
If your muscles have memorized all of the Bash prestidigitations, this page
will help you put a finger on how to do the equivelent task in xonsh.
2016-05-07 13:40:55 -04:00
.. list-table::
2016-02-04 22:37:45 -05:00
:widths: 30 30 40
:header-rows: 1
* - Bash
- Xonsh
- Notes
* - ``$NAME`` or ``${NAME}``
- ``$NAME``
- Look up an environment variable by name.
* - ``${${VAR}}``
- ``${var or expr}``
2016-05-07 13:40:55 -04:00
- Look up an environment variable via another variable name. In xonsh,
2016-02-04 22:37:45 -05:00
this may be any valid expression.
* - ``$(cmd args)`` or ```cmd args```
- ``$(cmd args)``
- Use the ``$()`` operator to capture subprocesses as strings. Bash's
2016-05-07 13:40:55 -04:00
version of (now-deprecated) backticks is not supported. Note that
Bash will automatically tokenize the string, while xonsh just returns
2016-02-04 22:37:45 -05:00
a str of stdout.
* - ``set -e``
- ``$RAISE_SUBPROC_ERROR = True``
2016-05-07 13:40:55 -04:00
- Cause a failure after a non-zero return code. Xonsh will raise a
2016-02-04 22:37:45 -05:00
``supbrocess.CalledProcessError``.
* - ``set -x``
- ``trace on``
- Turns on tracing of source code lines during execution.
2016-02-10 03:22:30 -05:00
* - ``&&``
- ``and`` or ``&&``
- Logical-and operator for subprocesses.
* - ``||``
- ``or`` as well as ``||``
- Logical-or operator for subprocesses.
2016-05-07 13:40:55 -04:00
* - ``$?``
- ``__xonsh_history__.rtns[-1]``
- Returns the exit code, or status, of the previous command.