<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!--This manual describes what the CentOS Artwork Repository is and what
can you do inside it.
Copyright C 2009, 2010 Alain Reguera Delgado. All rights
reserved.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
copy of the license is included in the section entitled GNU Free
Documentation License.
-->
<!-- Created on November, 5 2010 by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>
-->
<head>
<title>CentOS Artwork Repository: 3.35 trunk/Scripts/Bash/Functions</title>
<meta name="description" content="CentOS Artwork Repository: 3.35 trunk/Scripts/Bash/Functions">
<meta name="keywords" content="CentOS Artwork Repository: 3.35 trunk/Scripts/Bash/Functions">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
@import "/home/centos/artwork/trunk/Identity/Models/Css/Texi2html/common.css";
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="repository_37.html#SEC199" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC201" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="repository_3.html#SEC3" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="repository_3.html#SEC3" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="repository_62.html#SEC342" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="repository.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="repository_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="repository_62.html#SEC342" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="repository_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="trunk-Scripts-Bash-Functions"></a>
<a name="SEC200"></a>
<h2 class="section"> 3.35 trunk/Scripts/Bash/Functions </h2>
<a name="SEC201"></a>
<h3 class="subsection"> 3.35.1 Goals </h3>
<p>The <tt>`trunk/Scripts/Bash/Functions'</tt> directory exists to organize
<tt>`centos-art.sh'</tt> specific functionalities.
</p>
<a name="SEC202"></a>
<h3 class="subsection"> 3.35.2 Description </h3>
<p>The specific functions of <tt>`centos-art.sh'</tt> script are designed
with "Software Toolbox" philosophy (see <a href="../coreutils/Toolbox-introduction.html#Toolbox-introduction">(coreutils.info)Toolbox introduction</a>) in mind: each program "should do one
thing well". Inside <tt>`centos-art.sh'</tt> script, each specific
functionality is considered a program that should do one thing well.
Of course, if you find that they still don't do it, feel free to
improve them in order for them to do so.
</p>
<p>The specific functions of <tt>`centos-art.sh'</tt> script are organized
inside specific directories under <tt>`trunk/Scripts/Bash/Functions'</tt>
location. Each specific function directory should be named as the
function it represents, with the first letter in uppercase. For
example, if the function name is <code>render</code>, the specific function
directory for it would be <samp>`trunk/Scripts/Bash/Functions/Render'</samp>.
</p>
<p>To better understand how specific functions of <tt>`centos-art.sh'</tt>
script are designed, lets create one function which only goal is to
output different kind of greetings to your screen.
</p>
<p>When we create specific functions for <tt>`centos-art.sh'</tt> script it
is crucial to know what these functions will do exactly and if there
is any function that already does what we intend to do. If there is no
one, it is good time to create them then. Otherwise, if
functionalities already available don't do what you exactly expect,
contact their authors and work together to improve them.
</p>
<blockquote class="orange"><img src="/home/centos/artwork/trunk/Identity/Widgets/Img/icon-admonition-idea.png" alt="Info"><h3>Tip</h3><p> Join CentOS developers mailing list
<a href="mailto:centos-art@centos.org">centos-art@centos.org</a> to share your ideas.
</p></blockquote>
<p>It is also worth to know what global functions do we have available
inside <tt>`centos-art.sh'</tt> script, so advantage can be taken from
them. Global functions are stored immediatly under
<tt>`trunk/Scripts/Bash/Functions'</tt> directory in files begining with
<samp>`cli'</samp> prefix.
</p>
<p>OK, let's begin with our functionality example.
</p>
<p>What function name do we use? Well, lets use <code>greet</code>. Note that
<samp>`hello'</samp> word is not a verb; but an expression, a kind of
greeting, an interjection specifically. In contrast, <samp>`greet'</samp> is a
verb and describes what we do when we say <samp>`Hello!'</samp>, <samp>`Hi!'</samp>,
and similar expressions.
</p>
<p>So far, we've gathered the following function information:
</p>
<pre class="verbatim">Name: greet
Path: trunk/Scripts/Bash/Functions/Greet
File: trunk/Scripts/Bash/Functions/Greet/greet.sh
</pre>
<p>The <tt>`greet.sh'</tt> function script is the first file
<tt>`centos-art.sh'</tt> script loads when the <samp>`greet'</samp> functionality
is called using commands like <samp>`centos-art greet --hello='World''</samp>.
The <tt>`greet.sh'</tt> function script contains the <code>greet</code> function
definition.
</p>
<p>Inside <tt>`centos-art.sh'</tt> script, as convenction, each function
script has one top commentary, followed by one blank line, and then
one function defintion below it only.
</p>
<p>Inside <tt>`centos-art.sh'</tt> script functions, top commentaries
describe function definition in the following five components:
one-line for copyright note with your personal information, the
license under which the function source code is released --the
<tt>`centos-art.sh'</tt> script is released as GPL, so do all its
functions--, subversion's <code>$Id$</code> keyword which is later expanded
by <code>svn propset</code> command.
</p>
<p>In our <code>greet</code> function example, top commentary for
<tt>`greet.sh'</tt> function script would look like the following:
</p>
<pre class="verbatim">#!/bin/bash
#
# greet.sh -- This function outputs different kind of greetings to
# your screen. Use this function to understand how centos-art.sh
# script specific functionalities work.
#
# Copyright (C) YEAR YOURFULLNAME
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
#
# ----------------------------------------------------------------------
# $Id$
# ----------------------------------------------------------------------
</pre>
<p>After top commentary, separated by one blank line, the <code>greet</code>
function definition would look like the following:
</p>
<pre class="verbatim">function greet {
# Define global variables.
# Define command-line interface.
greet_getActions
}
</pre>
<p>The first definition inside <code>greet</code> function, are global
variables that will be available along <code>greet</code> function execution
environment. This time we didn't use global variable definitions for
<code>greet</code> function execution environment, so we left that section
empty.
</p>
<p>Later, we call <code>greet_getActions</code> function to define the
command-line interface of <code>greet</code> functionality. The <code>greet</code>
functionality command-line interface defines what and how actions are
performed, based on arguments combination passed to
<tt>`centos-art.sh'</tt> script.
</p>
<pre class="verbatim">function greet_getActions {
case "$OPTIONNAM" in
--hello )
greet_doHello
;;
--bye )
greet_doBye
;;
* )
cli_printMessage "`gettext "The option provided is not valid."`"
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
esac
}
</pre>
<p>The <var>OPTIONNAM</var> global variable is defined in <tt>`cli.sh'</tt>
function script and contains the value passed before the equal sign
(i.e., <samp>`='</samp>) in the second command-line argument of
<tt>`centos-art.sh'</tt> script. For example, if the second command-line
argument is <samp>`--hello='World''</samp>, the value of <var>OPTIONNAM</var>
variable would be <samp>`--hello'</samp>. Using this configuration let us
deside which action to perform based on the option name passed to
<tt>`centos-art.sh'</tt> script as second argument.
</p>
<p>The <code>greet</code> function definition makes available two valid
greetings through <samp>`--hello'</samp> and <samp>`--bye'</samp> options. If no
one of them is provided as second command-line argument, the <samp>`*'</samp>
case is evaluated instead.
</p>
<p>The <samp>`*'</samp> case and its two further lines should always be present
in <tt>`_getActions.sh'</tt> function scripts, no matter what specific
functionality you are creating. This convenction helps the user to
find out documentation about current functionality in use.
</p>
<p>The <code>greet_doHello</code> and <code>greet_doBye</code> function definitions
are the core of <code>greet</code> specific functionality. In such function
definitions we set what our <code>greet</code> function really does: to
output different kinds of greetings.
</p>
<pre class="verbatim">function greet_doHello {
cli_printMessage "`gettext "Hello"` $OPTIONVAL"
}
</pre>
<p>The <code>greet_doHello</code> function definition is stored in
<tt>`greet_doHello.sh'</tt> function script.
</p>
<pre class="verbatim">function greet_doBye {
cli_printMessage "`gettext "Goodbye"` $OPTIONVAL"
}
</pre>
<p>The <code>greet_doBye</code> function definition is stored in the
<tt>`greet_doBye.sh'</tt> function script.
</p>
<p>Both <tt>`greet_doHello.sh'</tt> and <tt>`greet_doBye.sh'</tt> function
scripts are stored inside <code>greet</code>'s function directory path (i.e.
<tt>`trunk/Scripts/Bash/Functions/Greet'</tt>).
</p>
<p>The <var>OPTIONVAL</var> global variable is defined in <tt>`cli.sh'</tt>
function script and contains the value passed after the equal sign
(i.e., <samp>`='</samp>) in the second command-line argument of
<tt>`centos-art.sh'</tt> script. For example, if the second command-line
argument is <samp>`--hello='World''</samp>, the value of <var>OPTIONVAL</var>
variable would be <samp>`World'</samp> without quotes.
</p>
<p>Let's see how <code>greet</code> specific functionality files are organzied
under <code>greet</code>'s function directory. To see file organization we
use the <code>tree</code> command:
</p>
<pre class="verbatim">trunk/Scripts/Bash/Functions/Greet
|-- greet_doBye.sh
|-- greet_doHello.sh
|-- greet_getActions.sh
`-- greet.sh
</pre>
<p>To try the <code>greet</code> specific functionality we've just created,
pass the function name (i.e., <samp>`greet'</samp>) as first argument to
<tt>`centos-art.sh'</tt> script, and any of the valid options as second
argument. Some examples are illustrated below:
</p>
<pre class="verbatim">[centos@projects ~]$ centos-art greet --hello='World'
Hello World
[centos@projects ~]$ centos-art greet --bye='World'
Goodbye World
[centos@projects ~]$
</pre>
<p>The word <samp>`World'</samp> in the examples above can be anything. In fact,
change it to have a little fun.
</p>
<p>Now that we have a specific function that works as we expect, it is
time to document it. To document <code>greet</code> specific functionality,
we use its directory path and the <code>help</code> functionality
(see section <a href="repository_39.html#SEC208">trunk/Scripts/Bash/Functions/Help</a>) of <tt>`centos-art.sh'</tt>
script, just as the following command illustrates:
</p>
<pre class="verbatim">centos-art help --edit=trunk/Scripts/Bash/Functions/Greet
</pre>
<p>Now that we have documented our function, it is time to translate its
output messages to different languages. To translate specific
functionality output messages to different languages we use the
<code>locale</code> functionality (see section <a href="repository_41.html#SEC218">trunk/Scripts/Bash/Functions/Locale</a>) of <tt>`centos-art.sh'</tt> script, just as the following command
illustrates:
</p>
<pre class="verbatim">centos-art locale --edit
</pre>
<blockquote class="orange"><img src="/home/centos/artwork/trunk/Identity/Widgets/Img/icon-admonition-alert.png" alt="Warning"><h3>Warning</h3><p> To translate output messages in different languages,
your system locale information --as in <code>LANG</code> environment
variable-- must be set to that locale you want to produce translated
messages for. For example, if you want to produce translated messages
for Spanish language, your system locale information must be set to
<samp>`es_ES.UTF-8'</samp> or similar.
</p></blockquote>
<p>Well, it seems that our example is rather complete by now.
</p>
<p>In <code>greet</code> function example we've described so far, we only use
<code>cli_printMessage</code> global function in action specific function
definitions in order to print a message simply, but more interesting
things can be achieved inside action specific function definitions.
For example, if you pass a directory path as second argument option
value, you could retrive a list of files from therein, and process
them. If the list of files turns too long or you just want to control
which files to process, you could add the third argument in the form
<samp>`--filter='regex''</samp> and reduce the amount of files to process
using a regular expression pattern.
</p>
<p>The <code>greet</code> function described in this section may serve you as
an introduction to understand how specific functionalities work inside
<tt>`centos-art.sh'</tt> script. With some of luck this introduction will
also serve you as motivation to create your own <tt>`centos-art.sh'</tt>
script specific functionalities.
</p>
<p>By the way, the <code>greet</code> functionality doesn't exist inside
<tt>`centos-art.sh'</tt> script yet. Would you like to create it?
</p>
<a name="SEC203"></a>
<h3 class="subsection"> 3.35.3 Usage </h3>
<a name="SEC204"></a>
<h4 class="subsubsection"> 3.35.3.1 Global variables </h4>
<p>The following global variables of <tt>`centos-art.sh'</tt> script, are
available for you to use inside specific functions:
</p>
<dl>
<dt><u>Variable:</u> <b>TEXTDOMAIN</b>
<a name="IDX1"></a>
</dt>
<dd><p>Default domain used to retrieve translated messages. This value is set
in <tt>`initFunctions.sh'</tt> and shouldn't be changed.
</p></dd></dl>
<dl>
<dt><u>Variable:</u> <b>TEXTDOMAINDIR</b>
<a name="IDX2"></a>
</dt>
<dd><p>Default directory used to retrieve translated messages. This value is
set in <tt>`initFunctions.sh'</tt> and shouldn't be changed.
</p></dd></dl>
<dl>
<dt><u>Variable:</u> <b>ACTION</b>
<a name="IDX3"></a>
</dt>
<dd><p>Default action passed as first argument in <tt>`centos-art.sh'</tt>
command-line interface. For example, in the command <samp>`centos-art
render --entry=path/to/dir --filter=regex'</samp>, the <var>ACTION</var> passed to
<tt>`centos-art.sh'</tt> script is <samp>`render'</samp>.
</p></dd></dl>
<dl>
<dt><u>Variable:</u> <b>OPTIONNAM</b>
<a name="IDX4"></a>
</dt>
<dd><p>Default option name passed as second argument in <tt>`centos-art.sh'</tt>
command-line interface. For example, in the command <samp>`centos-art
render --entry=path/to/dir --filter=regex'</samp>, the <var>OPTIONNAM</var> passed
to <tt>`centos-art.sh'</tt> script is <samp>`--entry'</samp>.
</p></dd></dl>
<dl>
<dt><u>Variable:</u> <b>OPTIONVAL</b>
<a name="IDX5"></a>
</dt>
<dd><p>Default option value passed as second argument in <tt>`centos-art.sh'</tt>
command-line interface. For example, in the command <samp>`centos-art
render --entry=path/to/dir --filter=regex'</samp>, the <var>OPTIONVAL</var> passed
to <tt>`centos-art.sh'</tt> script is <samp>`path/to/dir'</samp>.
</p></dd></dl>
<dl>
<dt><u>Variable:</u> <b>REGEX</b>
<a name="IDX6"></a>
</dt>
<dd><p>Default option value passed as third argument in <tt>`centos-art.sh'</tt>
command-line interface. For example, in the command <samp>`centos-art
render --entry=path/to/dir --filter=regex'</samp>, the <var>REGEX</var> passed to
<tt>`centos-art.sh'</tt> is <samp>`regex'</samp>.
</p>
<p>The third argument option name is not variable as second argument
option name is. The third argument option name is stocked to
<samp>`--filter'</samp> for whatever value it passed at the right side of
its equal sign.
</p>
<p>Generally, third argument option value is used to pass regular
expression patterns that modify the list of files to process, but this
is not the only feature <var>REGEX</var> may serve to.
</p></dd></dl>
<dl>
<dt><u>Variable:</u> <b>ANSWER</b>
<a name="IDX7"></a>
</dt>
<dd><p>Default answer to confirmation questions.
</p>
<p>As most questions request confirmation to perform some action, default
answer to <var>ANSWER</var> variable is negative (i.e., <samp>`No'</samp>).
Default answer value takes place when no value is entered as response
to confirmation questions before pressing <kbd>RET</kbd> key.
</p></dd></dl>
<dl>
<dt><u>Variable:</u> <b>TMPFILE</b>
<a name="IDX8"></a>
</dt>
<dd><p>Default location to store temporal files.
</p>
<p>The <var>TMPFILE</var> uses <tt>`/tmp'</tt> directory as source location to
store temporal files, the <tt>`centos-art.sh'</tt> script name, and the
process id of <tt>`centos-art.sh'</tt> script execution to let you run
more than one <tt>`centos-art.sh'</tt> script simultaneously on the same
user session. For example, due the following temporal file defintion:
</p>
<pre class="verbatim">${TMPFILE}-${FILE}
</pre>
<p>If <var>FILE</var> name is <tt>`instance.svg'</tt> and process id is
<samp>`3761'</samp>, the final temporal file built from previous temporal file
definition would be:
</p>
<pre class="verbatim">/tmp/centos-art.sh-3761-instance.svg
</pre>
<p>When you use <var>TMPFILE</var> global variable to create temporal files,
be sure to remove temporal files created once you've ended up with
them. For example, consider the following construction:
</p>
<pre class="verbatim">for FILE in $FILES;do
# Initialize temporal instance of file.
INSTANCE=${TMPFILE}-${FILE}
# Do something ...
# Remove temporal instance of file.
if [[ -f $INSTANCE ]];then
rm $INSTANCE
fi
done
</pre></dd></dl>
<dl>
<dt><u>Variable:</u> <b>EDITOR</b>
<a name="IDX9"></a>
</dt>
<dd><p>Default text editor.
</p>
<p>The <tt>`centos-art.sh'</tt> script uses default text <code>EDITOR</code> to edit
pre-commit subversion messages, translation files, configuration
files, script files, and similar text-based files.
</p>
<p>If <code>EDITOR</code> environment variable is not set, <tt>`centos-art.sh'</tt>
script uses <tt>`/usr/bin/vim'</tt> as default text editor. Otherwise, the
following values are recognized by <tt>`centos-art.sh'</tt> script:
</p>
<ul class="toc">
<li> <tt>`/usr/bin/vim'</tt>
</li><li> <tt>`/usr/bin/emacs'</tt>
</li><li> <tt>`/usr/bin/nano'</tt>
</li></ul>
<p>If no one of these values is set in <code>EDITOR</code> environment variable,
<tt>`centos-art.sh'</tt> uses <tt>`/usr/bin/vim'</tt> text editor by default.
</p></dd></dl>
<a name="SEC205"></a>
<h4 class="subsubsection"> 3.35.3.2 Global functions </h4>
<p>The following global functions of <tt>`centos-art.sh'</tt> script, are
available for you to use inside specific functions:
</p>
<dl>
<dt><u>Function:</u> <b>cli_commitRepoChanges</b>
<a name="IDX10"></a>
</dt>
<dd><p>Commit recent changes up to central repository.
</p>
<p>The <code>cli_commitRepoChanges</code> function uses the list of files
stored in the <var>FILES</var> variable and verifies changes inside your
repository working copy, using subversion commands. If
<code>cli_commitRepoChanges</code> finds changes inside your working copy,
it asks you for confirmation to commit them up to central repository.
</p>
<p>Call <code>cli_commitRepoChanges</code> function after functions that modify
files inside your repository working copy.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cli_checkFiles</b><i> FILE [TYPE]</i>
<a name="IDX11"></a>
</dt>
<dd><p>Verify files.
</p>
<p><code>cli_checkFiles</code> receives a <var>FILE</var> absolute path and performs
file verification as specified in <var>TYPE</var>. When <var>TYPE</var> is not
specified, <code>cli_checkFiles</code> verifies <var>FILE</var> existence, no
matter what kind of file it be. If <var>TYPE</var> is specified, use one
of the following values:
</p>
<dl compact="compact">
<dt> <samp>`d'</samp></dt>
<dt> <samp>`directory'</samp></dt>
<dd><p>Ends script execution if <var>FILE</var> is not a directory.
</p>
<p>When you verify directories with cli_checkFiles, if directory doesn't
exist, <tt>`centos-art.sh'</tt> script asks you for confirmation in order
to create that directory. If you answer positively,
<tt>`centos-art.sh'</tt> script creates that directory and continues
script flows normally. Otherwise, if you answer negatively,
<tt>`centos-art.sh'</tt> ends script execution with an error and
documentation message.
</p>
</dd>
<dt> <samp>`f'</samp></dt>
<dt> <samp>`regular-file'</samp></dt>
<dd><p>Ends script execution if <var>FILE</var> is not a regular file.
</p></dd>
<dt> <samp>`h'</samp></dt>
<dt> <samp>`symbolic-link'</samp></dt>
<dd><p>Ends script execution if <var>FILE</var> is not a symbolic link.
</p></dd>
<dt> <samp>`x'</samp></dt>
<dt> <samp>`execution'</samp></dt>
<dd><p>Ends script execution if <var>FILE</var> is not executable.
</p></dd>
<dt> <samp>`fh'</samp></dt>
<dd><p>Ends script execution if <var>FILE</var> is neither a regular file or a
symbolic link.
</p></dd>
</dl>
<p>As default behaviour, if <var>FILE</var> passes all verifications,
<tt>`centos-art.sh'</tt> script continues with its normal flow.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cli_getCountryCodes</b><i> [FILTER]</i>
<a name="IDX12"></a>
</dt>
<dd><p>Output country codes.
</p>
<p>The <code>cli_getCountryCodes</code> function outputs a list with country
codes as defined in ISO3166 standard. When <var>FILTER</var> is provided,
<code>cli_getCountryCodes</code> outputs country codes that match
<var>FILTER</var> regular expression pattern.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cli_getCountryName</b><i> [FILTER]</i>
<a name="IDX13"></a>
</dt>
<dd><p>Output country names.
</p>
<p>The <code>cli_getCountryName</code> function reads one language locale code
in the format LL_CC and outputs the name of its related country as in
ISO3166. If filter is specified, <code>cli_getCountryName</code> returns the
country name that matches the locale code specified in <var>FILTER</var>,
exactly.
</p>
<p>The <code>cli_getCountryName</code> function outputs country name supported
by <tt>`centos-art.sh'</tt> script.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cli_getCurrentLocale</b>
<a name="IDX14"></a>
</dt>
<dd><p>Output current locale used by <tt>`centos-art.sh'</tt> script.
</p>
<p>The <code>cli_getCurrentLocale</code> function uses <code>LANG</code> environment
variable to build a locale pattern that is later applied to
<code>cli_getLocales</code> function output in order to return the current
locale that <tt>`centos-art.sh'</tt> script works with.
</p>
<p>The current locale information, returned by
<code>cli_getCurrentLocale</code>, is output from more specific to less
specific. For example, if <samp>`en_GB'</samp> locale exists in
<code>cli_getLocales</code> function output, the <samp>`en_GB'</samp> locale would
take precedence before <samp>`en'</samp> locale.
</p>
<p>Locale precedence selection is quite important in order to define the
locale type we use for message translations. For example, if
<samp>`en_GB'</samp> is used, we are also saying that no common language
specification is used for English language (i.e., <samp>`en'</samp>). Instead,
we are using English non-common country-specific language
specifications like <samp>`en_AU'</samp>, <samp>`en_BW'</samp>, <samp>`en_GB'</samp>,
<samp>`en_US'</samp>, etc., for message translations.
</p>
<p>Use <code>cli_getCurrentLocale</code> function to know what current locale
information to use inside <tt>`centos-art.sh'</tt> script.
</p>
<p>The <code>cli_getCurrentLocale</code> function outputs current locale used
by <tt>`centos-art.sh'</tt> script.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cli_getLangCodes</b><i> [FILTER]</i>
<a name="IDX15"></a>
</dt>
<dd><p>Output language codes.
</p>
<p><code>cli_getLangCodes</code> function outputs a list of language codes as
defined in ISO639 standard. When <var>FILTER</var> is provided,
<code>cli_getLangCodes</code> outputs language codes that match <var>FILTER</var>
regular expression pattern.
</p>
<p>The <code>cli_getLangCodes</code> function outputs language codes supported
by <tt>`centos-art.sh'</tt> script.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cli_getLangName</b><i> [FILTER]</i>
<a name="IDX16"></a>
</dt>
<dd><p>Output language names.
</p>
<p><code>cli_getLangName</code> function reads one language locale code in the
format LL_CC and outputs the language related name as in ISO639. If
filter is specified, <code>cli_getLangName</code> returns the language name
that matches the locale code specified in <var>FILTER</var>, exactly.
</p>
<p>The <code>cli_getLangName</code> function outputs language names supported
by <tt>`centos-art.sh'</tt> script.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cli_getLocales</b>
<a name="IDX17"></a>
</dt>
<dd><p>Output locale codes supported by <tt>`centos-art.sh'</tt> script.
</p>
<p>Occasionally, you use <code>cli_getLocales</code> function to add locale
information in non-common country-specific language (<samp>`LL_CC'</samp>)
format for those languages (e.g., <samp>`bn_IN'</samp>, <samp>`pt_BR'</samp>, etc.)
which locale differences cannot be solved using common language
specifications (<samp>`LL'</samp>) into one unique common locale specification
(e.g., <samp>`bn'</samp>, <samp>`pt'</samp>, etc.).
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cli_getRepoName</b><i> NAME TYPE</i>
<a name="IDX18"></a>
</dt>
<dd><p>Sanitate file names.
</p>
<p>Inside <tt>`centos-art.sh'</tt> script, specific functionalities rely both
in <code>cli_getRepoName</code> and repository file system organization to
achieve their goals. Consider <code>cli_getRepoName</code> function as
central place to manage file name convenctions for other functions
inside <tt>`centos-art.sh'</tt> script.
</p>
<blockquote class="orange"><img src="/home/centos/artwork/trunk/Identity/Widgets/Img/icon-admonition-alert.png" alt="Warning"><h3>Warning</h3><p> <code>cli_getRepoName</code> function doesn't verify file
or directory existence, for that purpose use <code>cli_checkFiles</code>
function instead.
</p></blockquote>
<p>The <var>NAME</var> variable contains the file name or directory name you
want to sanitate.
</p>
<p>The <var>TYPE</var> variable can be one of the following values:
</p><dl compact="compact">
<dt> <samp>`d'</samp></dt>
<dt> <samp>`directory'</samp></dt>
<dd><p>Sanitate directory <var>NAME</var>s.
</p></dd>
<dt> <samp>`f'</samp></dt>
<dt> <samp>`regular-file'</samp></dt>
<dd><p>Sanitate regular file <var>NAME</var>s.
</p></dd>
</dl>
<p>Use <code>cli_getRepoName</code> function to sanitate file names and
directory names before their utilization.
</p>
<p>Use <code>cli_getRepoName</code> when you need to change file name
convenctions inside <tt>`centos-art.sh'</tt> script.
</p>
<p>When changing file name convenctions inside <code>cli_getRepoName</code>
what you are really changing is the way functions interpret repository
file system organization. In order to a complete file name convenction
change, you also need to change file names and directory names inside
repository file system organization, just as you did in
<code>cli_getRepoName</code> function.
</p>
<blockquote class="blue"><img src="/home/centos/artwork/trunk/Identity/Widgets/Img/icon-admonition-info.png" alt="info"><h3>Note</h3><p> See section <a href="repository_42.html#SEC223">trunk/Scripts/Bash/Functions/Path</a>, for more
information on how to rename files and directories massively inside
repository file system organization.
</p></blockquote>
</dd></dl>
<dl>
<dt><u>Function:</u> <b>cli_getThemeName</b>
<a name="IDX19"></a>
</dt>
<dd><p>Output theme name.
</p>
<p>In order for <code>cli_getThemeName</code> function to extract theme name
correctly, the <var>OPTIONVAL</var> variable must contain a directory path
under <tt>`trunk/Identity/Themes/Motifs/'</tt> directory structure.
Otherwise, <code>cli_getThemeName</code> returns an empty string.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cli_printMessage</b><i> MESSAGE [FORMAT]</i>
<a name="IDX20"></a>
</dt>
<dd><p>Give format to output messages.
</p>
<p>When <var>FORMAT</var> is not specified, <code>cli_printMessage</code> outputs
information just as it was passed in <var>MESSAGE</var> variable.
Otherwise, <var>FORMAT</var> can take one of the following values:
</p>
<dl compact="compact">
<dt> <samp>`AsHeadingLine'</samp></dt>
<dd><p>To print heading messages.
</p><pre class="verbatim">----------------------------------------------------------------------
$MESSAGE
----------------------------------------------------------------------
</pre>
</dd>
<dt> <samp>`AsWarningLine'</samp></dt>
<dd><p>To print warning messages.
</p><pre class="verbatim">----------------------------------------------------------------------
WARNING: $MESSAGE
----------------------------------------------------------------------
</pre>
</dd>
<dt> <samp>`AsNoteLine'</samp></dt>
<dd><p>To print note messages.
</p><pre class="verbatim">----------------------------------------------------------------------
NOTE: $MESSAGE
----------------------------------------------------------------------
</pre>
</dd>
<dt> <samp>`AsUpdatingLine'</samp></dt>
<dd><p>To print <samp>`Updating'</samp> messages using two-columns format.
</p><pre class="verbatim">Updating $MESSAGE
</pre>
</dd>
<dt> <samp>`AsRemovingLine'</samp></dt>
<dd><p>To print <samp>`Removing'</samp> messages using two-columns format.
</p><pre class="verbatim">Removing $MESSAGE
</pre>
</dd>
<dt> <samp>`AsCheckingLine'</samp></dt>
<dd><p>To print <samp>`Checking'</samp> messages using two-columns format.
</p><pre class="verbatim">Checking $MESSAGE
</pre>
</dd>
<dt> <samp>`AsCreatingLine'</samp></dt>
<dd><p>To print <samp>`Creating'</samp> messages using two-columns format.
</p><pre class="verbatim">Creating $MESSAGE
</pre>
</dd>
<dt> <samp>`AsSavedAsLine'</samp></dt>
<dd><p>To print <samp>`Saved as'</samp> messages using two-columns format.
</p><pre class="verbatim">Saved as $MESSAGE
</pre>
</dd>
<dt> <samp>`AsLinkToLine'</samp></dt>
<dd><p>To print <samp>`Linked to'</samp> messages using two-columns format.
</p><pre class="verbatim">Linked to $MESSAGE
</pre>
</dd>
<dt> <samp>`AsMovedToLine'</samp></dt>
<dd><p>To print <samp>`Moved to'</samp> messages using two-columns format.
</p><pre class="verbatim">Moved to $MESSAGE
</pre>
</dd>
<dt> <samp>`AsTranslationLine'</samp></dt>
<dd><p>To print <samp>`Translation'</samp> messages using two-columns format.
</p><pre class="verbatim">Translation $MESSAGE
</pre>
</dd>
<dt> <samp>`AsConfigurationLine'</samp></dt>
<dd><p>To print <samp>`Configuration'</samp> messages using two-columns format.
</p><pre class="verbatim">Configuration $MESSAGE
</pre>
</dd>
<dt> <samp>`AsResponseLine'</samp></dt>
<dd><p>To print response messages using one-column format.
</p><pre class="verbatim">--> $MESSAGE
</pre>
</dd>
<dt> <samp>`AsRequestLine'</samp></dt>
<dd><p>To print request messages using one-column format. Request messages
supress the trailing newline character from final output.
</p><pre class="verbatim">$MESSAGE
</pre>
</dd>
<dt> <samp>`AsYesOrNoRequestLine'</samp></dt>
<dd><p>To print <samp>`yes or no'</samp> request messages using one-column format. If
something different from <samp>`y'</samp> is answered (when using
<code>en_US.UTF-8</code> locale), script execution ends immediatly.
</p>
<pre class="verbatim">$MESSAGE [y/N]:
</pre>
<p>When you are using <tt>`centos-art.sh'</tt> script in a locale different
from <code>en_US.UTF-8</code>, confirmation answer may be different from
<samp>`y'</samp>. For example, if you are using <code>es_ES.UTF-8</code> locale, the
confirmation question would look like:
</p>
<pre class="verbatim">$MESSAGE [s/N]:
</pre>
<p>and the confirmation answer would be <samp>`s'</samp>, as it is on Spanish
<samp>`sí'</samp> word.
</p>
<p>Definition of which confirmation word to use is set on translation
messages for your specific locale information. See section <a href="repository_41.html#SEC218">trunk/Scripts/Bash/Functions/Locale</a>, for more information about locale-specific
translation messages.
</p>
</dd>
<dt> <samp>`AsToKnowMoreLine'</samp></dt>
<dd><p>To standardize <samp>`to know more, run the following command:'</samp>
messages. When the <samp>`AsToKnowMoreLine'</samp> option is used, the
<var>MESSAGE</var> value should be set to <code>"$(caller)"</code>. <code>caller</code>
is a Bash builtin that returns the context of the current subroutine
call. <samp>`AsToKnowMoreLine'</samp> option uses <code>caller</code> builtin
output to build documentation entries dynamically.
</p>
<pre class="verbatim">----------------------------------------------------------------------
To know more, run the following command:
centos-art help --read='path/to/dir'
----------------------------------------------------------------------
</pre>
<p>Use <samp>`AsToKnowMoreLine'</samp> option after errors and for intentional
script termination.
</p>
</dd>
<dt> <samp>`AsRegularLine'</samp></dt>
<dd><p>To standardize regular messages using one-column format.
</p>
<p>When <var>MESSAGE</var> contains a colon inside (e.g., <samp>`description:
message'</samp>), the <code>cli_printMessage</code> function outputs <var>MESSAGE</var>
using two-columns format.
</p></dd>
</dl>
<blockquote class="orange"><img src="/home/centos/artwork/trunk/Identity/Widgets/Img/icon-admonition-idea.png" alt="Info"><h3>Tip</h3><p> To improve two-columns format, change the following file:
</p><pre class="verbatim">trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
</pre></blockquote>
<p>Use <code>cli_printMessage</code> function whenever you need to output
information from <tt>`centos-art.sh'</tt> script.
</p></dd></dl>
<a name="SEC206"></a>
<h4 class="subsubsection"> 3.35.3.3 Specific functions </h4>
<p>The following specific functions of <tt>`centos-art.sh'</tt> script, are
available for you to use:
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="repository_39.html#SEC208">3.36 trunk/Scripts/Bash/Functions/Help</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="repository_40.html#SEC213">3.37 trunk/Scripts/Bash/Functions/Html</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="repository_41.html#SEC218">3.38 trunk/Scripts/Bash/Functions/Locale</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="repository_42.html#SEC223">3.39 trunk/Scripts/Bash/Functions/Path</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="repository_43.html#SEC228">3.40 trunk/Scripts/Bash/Functions/Render</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="repository_44.html#SEC233">3.41 trunk/Scripts/Bash/Functions/Render/Config</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="repository_45.html#SEC241">3.42 trunk/Scripts/Bash/Functions/Shell</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="repository_46.html#SEC246">3.43 trunk/Scripts/Bash/Functions/Svg</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="repository_47.html#SEC251">3.44 trunk/Scripts/Bash/Functions/Verify</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<a name="SEC207"></a>
<h3 class="subsection"> 3.35.4 See also </h3>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="repository_37.html#SEC195">3.34 trunk/Scripts/Bash</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="repository_48.html#SEC259">3.45 trunk/Scripts/Bash/Locale</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC206" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="repository_39.html#SEC208" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="repository_3.html#SEC3" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC200" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="repository_62.html#SEC342" title="Next chapter"> >> </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated on <i>November, 5 2010</i> using <a href="http://texi2html.cvshome.org/"><i>texi2html 1.76</i></a>.
</font>
<br>
</p>
</body>
</html>