Blame Documentation/Models/Docbook/Tcar-ug/Scripts/Bash/environment.docbook

a01c20
<sect1 id="scripts-bash-environment">
a01c20
f751d7
    <title>Execution Environments</title>
f751d7
f751d7
    <para>
f751d7
        This section describes both variables and functions used by
f751d7
        <command>centos-art.sh</command> script as well as the related
f751d7
        execution environments they take place on.
f751d7
    </para>
f751d7
f751d7
    <para>
f751d7
        The execution environment of <command>centos-art.sh</command>
f751d7
        script can be defined as the virtual boundery of memory in
f751d7
        which the script does what it was conceived to do once
f751d7
        executed by a command-line interpreter (e.g., Bash). When you
f751d7
        execute the <command>centos-art.sh</command> script in your
f751d7
        terminal, the interpreter behind it creates a new execution
f751d7
        environment for it which inherits all the variables and
f751d7
        functions set in the shell execution environment and those
f751d7
        exported to it through the
f751d7
        <filename>~/.bash_profile</filename> file, as well.
f751d7
    </para>
f751d7
f751d7
    <para>
f751d7
        The <command>centos-art.sh</command> script uses the
f751d7
        <filename>~/.bash_profile</filename> file to implement
f751d7
        per-user customizations.  For example, you can use this file
f751d7
        to set the location of your working copy through the
f751d7
        <envar>TCAR_WORKDIR</envar> enviroment variable. By default
f751d7
        this variable is set to 
f751d7
        class="directory">${HOME}/artwork</filename>, but you can
f751d7
        reset to something different to fit your needs. See 
f751d7
        linkend="repo-ws-config-ChangeWorkingCopy" />.
f751d7
    </para>
f751d7
f751d7
    <para>
f751d7
        Once the <command>centos-art.sh</command> script has been
f751d7
        executed, it creates different levels of execution
f751d7
        environments inside the one created by the script itself on
f751d7
        the shell.  This different levels can be seen as a tree of
f751d7
        execution environments which inherit one another, as
f751d7
        illustrated in <xref linkend="scripts-bash-environments-1" />.
f751d7
        These different levels of execution evironments are where the
f751d7
        <command>centos-art.sh</command> script is developed in.
f751d7
    </para>
f751d7
f751d7
    <example id="scripts-bash-environments-1">
f751d7
    <title>Execution environments</title>
a01c20
    <screenshot>
f751d7
    <screeninfo>Execution environments</screeninfo>
a01c20
    <mediaobject>
a01c20
    <textobject>
a01c20
<programlisting>
f751d7
---------------------------------------------------------------
f751d7
Shell execution environment
f751d7
----|-------------------|--------------------------------------
f751d7
.   |-- TCAR_WORKDIR    |-- EDITOR                            .
f751d7
.   |-- LANG            |-- HOME                              .
f751d7
.   `-- centos-art.sh   `-- ...                               .
f751d7
.       ----|------------------------------------------------ .
f751d7
.       centos-art.sh script execution environment            .
f751d7
.       ----|--------------------|--------------------------- .
f751d7
.       .   |-- CLI_NAME         `-- cli()                  . .
f751d7
.       .   |-- CLI_VERSION          |-- render()           . .
f751d7
.       .   |-- CLI_BASEDIR          |   |-- svg()          . .
f751d7
.       .   |-- CLI_FUNCDIR          |   `-- docbook()      . .
f751d7
.       .   |-- TMPDIR               |-- help()             . .
f751d7
.       .   `-- ...                  |   |-- docbook()      . .
f751d7
.       .                            |   `-- texinfo()      . .
f751d7
.       .                            |-- locale()           . .
f751d7
.       .                            |-- cli_printMessage() . .
f751d7
.       .                            |-- cli_getFilesList() . .
f751d7
.       .                            `-- ...                . .
f751d7
.       ..................................................... .
f751d7
...............................................................
a01c20
</programlisting>
a01c20
    </textobject>
a01c20
    </mediaobject>
a01c20
    </screenshot>
a01c20
    </example>
a01c20
a01c20
    <para>
f751d7
        The first file <command>centos-art.sh</command> script calls
f751d7
        is the
f751d7
        <filename>trunk/Scripts/Bash/Functions/Common/cli.sh</filename>
f751d7
        file. This file initializes variables and functions used along
f751d7
        the script execution environment.  Such variables are for
f751d7
        internal use inside the <command>centos-art.sh</command>
f751d7
        script only and users shouldn't modify them to customize the
f751d7
        script in a per-user level.  Instead, to customize the script
f751d7
        behaviour in a per-user level, users need to make use of
f751d7
        environment variables set in
f751d7
        <filename>~/.bash_profile</filename> file.
f751d7
    </para>
f751d7
f751d7
    <para>
f751d7
        The functions initialized by
f751d7
        <filename>trunk/Scripts/Bash/Functions/Common/cli.sh</filename>
f751d7
        can be either common or specific. Common functionalities are
f751d7
        always loaded in each execution of centos-art.sh script.
f751d7
        Common functionalities are stored in the 
f751d7
        class="directory">trunk/Scripts/Bash/Functions/Commons/</filename>
f751d7
        directory and are made available for all specific
f751d7
        functionalities loaded later. Specific functionalities, on the
f751d7
        other hand, are loaded based in the first argument passed to
f751d7
        <command>centos-art.sh</command> script and are not available
f751d7
        for common functionalities. Specific functionalities are
f751d7
        stored in the 
f751d7
        class="directory">trunk/Scripts/Bash/Functions/${CLI_FUNCDIRNAM}</filename>
f751d7
        directory.
a01c20
    </para>
a01c20
    
a01c20
    <para>
f751d7
        In <xref linkend="scripts-bash-environments-1" />,
f751d7
        <function>render</function>, <function>help</function> and
f751d7
        <function>locale</function> are all specific functions while
f751d7
        <function>cli_printMessage</function> and
f751d7
        <function>cli_getFilesList</function> are common
f751d7
        functionality.
a01c20
    </para>
a01c20
f751d7
    <sect2 id="scripts-bash-environments-variables">
f751d7
    <title>Environment Variables</title>
a01c20
a01c20
    <para>
f751d7
        The <command>centos-art.sh</command> script uses the following
f751d7
        system environment variables:
a01c20
    </para>
a01c20
f751d7
    <variablelist>
f751d7
    <varlistentry>
f751d7
    <term><envar>PATH</envar></term>
f751d7
    <listitem>
a01c20
    <para>
f751d7
        The <envar>PATH</envar> environment variable is specific to
f751d7
        the operating system and provides search paths for command
f751d7
        execution.  By default, the centos-art.sh script links
f751d7
        executable scripts from the 
f751d7
        class="directory">~/bin</filename> directory which is one of
f751d7
        the locations used as search path in this variable. This is
f751d7
        how we create the <command>centos-art</command> command from
f751d7
        the <command>centos-art.sh</command> script  inside your
f751d7
        working copy.
a01c20
    </para>
a01c20
a01c20
    <para>
f751d7
        This variable is not initialized inside the
f751d7
        <command>centos-art.sh</command> script. Instead, the value
f751d7
        set in <filename>~/.bash_profile</filename> file is used. 
a01c20
    </para>
a01c20
f751d7
    </listitem>
f751d7
    </varlistentry>
f751d7
f751d7
    <varlistentry>
f751d7
    <term><envar>EDITOR</envar></term>
f751d7
    <listitem>
a01c20
    <para>
f751d7
        The <envar>EDITOR</envar> environment variable is specific to
f751d7
        the operating system and provides the path to your default
f751d7
        text editor. The <command>centos-art.sh</command> script uses
f751d7
        the default text editor to edit subversion pre-commit
f751d7
        messages, translation files, documentation files, script
f751d7
        files, and similar text-based files.  
f751d7
    </para>
f751d7
    
f751d7
    <para>
f751d7
        Possible values for this variable are:
f751d7
    </para>
a01c20
f751d7
    <itemizedlist>
a01c20
        <listitem>
a01c20
        <para>
a01c20
            <filename class="directory">/usr/bin/vim</filename>
a01c20
        </para>
a01c20
        </listitem>
a01c20
a01c20
        <listitem>
a01c20
        <para>
a01c20
        <filename class="directory">/usr/bin/emacs</filename>
a01c20
        </para>
a01c20
        </listitem>
a01c20
a01c20
        <listitem>
a01c20
        <para>
a01c20
            <filename class="directory">/usr/bin/nano</filename>
a01c20
        </para>
a01c20
        </listitem>
f751d7
    </itemizedlist>
a01c20
f751d7
    <para>
f751d7
        In case none of these values is set for the
f751d7
        <envar>EDITOR</envar> environment variable inside
f751d7
        <filename>~/.bash_profile</filename>, the
f751d7
        <command>centos-art.sh</command> script uses 
f751d7
        class="directory">/usr/bin/vim</filename> as default text
f751d7
        editor. This is the default text editor installed by default
f751d7
        in &TC;;. 
a01c20
    </para>
a01c20
f751d7
    </listitem>
f751d7
    </varlistentry>
f751d7
    <varlistentry>
f751d7
    <term><varname>TEXTDOMAIN</varname></term>
f751d7
    <listitem>
a01c20
    <para>
f751d7
        The <envar>TEXTDOMAIN</envar> environment variable is specific
f751d7
        to the operating system and provides the domain name of that
f751d7
        application we are producing translation messages for. This
f751d7
        variable, in combination with <envar>TEXTDOMAINDIR</envar>, is
f751d7
        used by <application>gettext</application> to find out the
f751d7
        location of translation messages.  In the very specific case
f751d7
        of <command>centos-art.sh</command> script we use the
f751d7
        <literal>centos-art.sh</literal> name as domain name.
a01c20
    </para>
f751d7
    
f751d7
    <para>
f751d7
        This variable is initialized inside the
f751d7
        <command>centos-art.sh</command> script, so if you set it
f751d7
        outside it (e.g., in <filename>~/.bash_profile</filename>) the
f751d7
        value you set there will be overwritten by that one set inside
f751d7
        <command>centos-art.sh</command> script, once it is executed.
f751d7
    </para>
f751d7
    </listitem>
f751d7
    </varlistentry>
a01c20
f751d7
    <varlistentry>
f751d7
    <term><varname>TEXTDOMAINDIR</varname></term>
f751d7
    <listitem>
a01c20
    <para>
f751d7
        The <envar>TEXTDOMAINDIR</envar> environment variable is
f751d7
        specific to the operating system and provides the absolute
f751d7
        path to the directory containing the translation messages
f751d7
        related to that application specified by
f751d7
        <envar>TEXTDOMAIN</envar> environment variable.  In the very
f751d7
        specific case of <command>centos-art.sh</command> script we
f751d7
        use the 
f751d7
        class="directory">trunk/Locales/Scripts/Bash</filename>
f751d7
        path as default value.
f751d7
    </para>
f751d7
    <para>
f751d7
        This variable is initialized inside the
f751d7
        <command>centos-art.sh</command> script, so if you set it
f751d7
        outside it (e.g., in <filename>~/.bash_profile</filename>) the
f751d7
        value you set there will be overwritten by that one set inside
f751d7
        <command>centos-art.sh</command> script, once it is executed.
f751d7
    </para>
f751d7
    </listitem>
f751d7
    </varlistentry>
f751d7
f751d7
    <varlistentry>
f751d7
    <term><envar>TMPDIR</envar></term>
f751d7
    <listitem>
f751d7
    <para>
f751d7
        The <envar>TMPDIR</envar> environment variable is specific to
f751d7
        the operating system and provides the absolute path to the
f751d7
        temporal directory the centos-art.sh script will use along its
f751d7
        execution. This variable is defined inside the
f751d7
        <command>centos-art.sh</command> script itself using the
f751d7
        <command>mktemp</command> command and will be unique on each
f751d7
        script execution. Thus, you should be able to run several
f751d7
        instances of <command>centos-art.sh</command> script
f751d7
        simultaneously without any problem. 
f751d7
    </para>
f751d7
    
f751d7
    <para>
f751d7
        Each time you need to store temporal files, do it inside the
f751d7
        absolute path specified by this variable.
f751d7
    </para>
f751d7
f751d7
    <para>
f751d7
        This variable is initialized inside the
f751d7
        <command>centos-art.sh</command> script, so if you set it
f751d7
        outside it (e.g., in <filename>~/.bash_profile</filename>) the
f751d7
        value you set there will be overwritten by that one set inside
f751d7
        <command>centos-art.sh</command> script, once it is executed.
f751d7
    </para>
f751d7
    </listitem>
f751d7
    </varlistentry>
f751d7
f751d7
    <varlistentry>
f751d7
    <term><envar>LANG</envar></term>
f751d7
    <listitem>
f751d7
    <para>
f751d7
        The <envar>LANG</envar> environment variable is specific to
f751d7
        the operating system and controls the default locale
f751d7
        information of it.  The <command>centos-art.sh</command>
f751d7
        script use the <envar>LANG</envar> environment variable to
f751d7
        determine what language to use for printing output messages
f751d7
        from the script itself, as well as the portable objects
f751d7
        locations that need to be updated or edited when you localize
f751d7
        directory structures inside the working copy of &TCAR;.
f751d7
    </para>
f751d7
        
f751d7
    <para>
f751d7
        The <envar>LANG</envar> environment variable is initially set
f751d7
        in the installation process of &TC;;, specifically in the
f751d7
        <emphasis>Language</emphasis> step.  Generally, there is no
f751d7
        need to customize this variable in your personal profile. If
f751d7
        you need to change the value of this environment variable do
f751d7
        it through the login screen of GNOME Desktop Environment or
f751d7
        the <command>system-config-language</command> command, or even
f751d7
        resetting the variable before executing the
f751d7
        <command>centos-art.sh</command> script.
f751d7
    </para>
f751d7
    </listitem>
f751d7
    </varlistentry>
f751d7
f751d7
    </variablelist>
f751d7
f751d7
    <para>
f751d7
        In addition to system environment variables described above,
f751d7
        the centos-art.sh script adds the following variables inside
f751d7
        the <filename>~/.bash_profile</filename> file to control the
f751d7
        script behaviour in a per-user level:
a01c20
    </para>
a01c20
f751d7
    <variablelist>
f751d7
    <varlistentry>
f751d7
    <term><varname>TCAR_WORKDIR</varname></term>
f751d7
    <listitem>
a01c20
    <para>
f751d7
        The <envar>TCAR_WORKDIR</envar> environment variable is
f751d7
        specific to <command>centos-art.sh</command> script and
f751d7
        controls the working copy default location in the workstation.
f751d7
        This variable doesn't exist just after installing your
f751d7
        workstation. In order for this variable to be customizable you
f751d7
        need to configure your workstation first, as described in
f751d7
        <xref linkend="repo-ws-config" />.
f751d7
    </para>
f751d7
    <para>
f751d7
        By default, when this variable hadn't been set, the
f751d7
        centos-art.sh script assumes the 
f751d7
        class="directory">${HOME}/artwork</filename> path as default
f751d7
        location for your working copy.
a01c20
    </para>
f751d7
    </listitem>
f751d7
    </varlistentry>
a01c20
f751d7
    <varlistentry>
f751d7
    <term><varname>TCAR_BRAND</varname></term>
f751d7
    <listitem>
a01c20
    <para>
f751d7
        ...   
a01c20
    </para>
f751d7
    </listitem>
f751d7
    </varlistentry>
f751d7
    </variablelist>
f751d7
f751d7
    </sect2>
f751d7
f751d7
    <sect2 id="scripts-bash-environment-functions">
f751d7
    <title>Environment Functions</title>
f751d7
f751d7
    <para>
f751d7
        In addition to environment variables described above, the
f751d7
        centos-art.sh script makes available the following common
f751d7
        environment functions:
f751d7
    </para>
f751d7
f751d7
    <variablelist>
f751d7
f751d7
    <varlistentry>
f751d7
    <term><function>cli_checkFiles <parameter>FILE</parameter> <parameter>...</parameter></function></term>
f751d7
    <listitem>
a01c20
    <para>
f751d7
        ...
a01c20
    </para>
f751d7
    </listitem>
f751d7
    </varlistentry>
a01c20
f751d7
    <varlistentry>
f751d7
    <term><function>cli_printMessage <parameter>MESSAGE</parameter> <parameter>TYPE</parameter></function></term>
f751d7
    <listitem>
a01c20
    <para>
f751d7
        ...
a01c20
    </para>
f751d7
    </listitem>
f751d7
    </varlistentry>
a01c20
f751d7
    <varlistentry>
f751d7
    <term><function>cli_exportFunctions <parameter>PATH</parameter></function></term>
f751d7
    <listitem>
a01c20
    <para>
f751d7
        ...
a01c20
    </para>
f751d7
    </listitem>
f751d7
    </varlistentry>
a01c20
f751d7
    </variablelist>
a01c20
    </sect2>
a01c20
f751d7
a01c20
</sect1>