diff --git a/docs/bash_to_xsh.rst b/docs/bash_to_xsh.rst index d5834f723..1beff3f0f 100644 --- a/docs/bash_to_xsh.rst +++ b/docs/bash_to_xsh.rst @@ -1,11 +1,7 @@ Bash to Xonsh Translation Guide ================================ -As you have probably figured out by now, xonsh is not ``sh``-lang compliant. -If your muscles have memorized all of the Bash prestidigitations, this page -will help you put a finger on how to do the equivalent task in xonsh. - -For shell scripts, the recommended file extension is ``xsh``, and shebang -line is ``#!/usr/bin/env xonsh``. +As you have probably figured out by now, xonsh is not POSIX compliant. +This page will help you put a finger on how to do the equivalent task in xonsh. .. list-table:: :widths: 30 30 40 @@ -14,6 +10,15 @@ line is ``#!/usr/bin/env xonsh``. * - Bash - Xonsh - Notes + * - No special object for represent session. + - ``__xonsh__`` + - The ``__xonsh__`` object has all about current xonsh session e.g. ``__xonsh__.env``. + * - ``script.sh`` + - ``script.xsh`` + - The recommended file extension is ``.xsh``. + * - ``#!/bin/bash`` + - ``#!/usr/bin/env xonsh`` + - Use ``xonsh`` in the shebang. * - ``echo --arg="val"`` ``echo {}`` @@ -33,7 +38,8 @@ line is ``#!/usr/bin/env xonsh``. characters, words or brackets. * - ``IFS`` - ``$XONSH_SUBPROC_OUTPUT_FORMAT`` - - Changing the output representation and splitting. + - Changing the output representation and splitting. Also take a look into ``DecoratorAlias`` + to have an ability to return object e.g. ``j = $(@json echo '{}')``. * - ``$NAME`` or ``${NAME}`` - ``$NAME`` - Look up an environment variable by name. @@ -59,7 +65,7 @@ line is ``#!/usr/bin/env xonsh``. * - ``ENV1=VAL1 command`` - ``$ENV1=VAL1 command`` - or ``with ${...}.swap(ENV1=VAL1): command`` + or ``with __xonsh__.env.swap(ENV1=VAL1): command`` - Set temporary environment variable(s) and execute the command. Use the second notation with an indented block to execute many commands in the same context. * - ``alias ll='ls -la'`` @@ -135,7 +141,7 @@ line is ``#!/usr/bin/env xonsh``. - Xonsh publishes a handful of containers, primarily targeting CI and automation use cases. All of them are published on `Docker Hub `_. * - ``exit 1`` - - ``exit(1)`` + - ``exit 1`` or ``exit(1)`` - Exiting from the current script. To understand how xonsh executes the subprocess commands try