Blame Manuals/en/Html/Repository/repository_41.html

4c79b5
4c79b5
<html>
6414c4
09d4f2
6414c4
Copyright C 2009, 2010, 2011  Alain Reguera Delgado
4c79b5
4c79b5
Permission is granted to copy, distribute and/or modify this document
4c79b5
under the terms of the GNU Free Documentation License, Version 1.2 or
4c79b5
any later version published by the Free Software Foundation; with no
4c79b5
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
4c79b5
copy of the license is included in the section entitled GNU Free
4c79b5
Documentation License.  
4c79b5
-->
92fb7f
4c79b5
4c79b5
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
4c79b5
            Karl Berry  <karl@freefriends.org>
4c79b5
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
4c79b5
            and many others.
4c79b5
Maintained by: Many creative people <dev@texi2html.cvshome.org>
4c79b5
Send bugs and suggestions to <users@texi2html.cvshome.org>
4c79b5
4c79b5
-->
4c79b5
<head>
aaa0e9
<title>The CentOS Artwork Repository: 3.38 trunk/Scripts/Bash/Functions</title>
4c79b5
aaa0e9
<meta name="description" content="The CentOS Artwork Repository: 3.38 trunk/Scripts/Bash/Functions">
aaa0e9
<meta name="keywords" content="The CentOS Artwork Repository: 3.38 trunk/Scripts/Bash/Functions">
4c79b5
<meta name="resource-type" content="document">
4c79b5
<meta name="distribution" content="global">
4c79b5
<meta name="Generator" content="texi2html 1.76">
4c79b5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4c79b5
<style type="text/css">
4c79b5
1e9202
@import "/home/centos/artwork/trunk/Identity/Models/Css/Texi2html/common.css";
4c79b5
4c79b5
a.summary-letter {text-decoration: none}
4c79b5
pre.display {font-family: serif}
4c79b5
pre.format {font-family: serif}
4c79b5
pre.menu-comment {font-family: serif}
4c79b5
pre.menu-preformatted {font-family: serif}
4c79b5
pre.smalldisplay {font-family: serif; font-size: smaller}
4c79b5
pre.smallexample {font-size: smaller}
4c79b5
pre.smallformat {font-family: serif; font-size: smaller}
4c79b5
pre.smalllisp {font-size: smaller}
4c79b5
span.sansserif {font-family:sans-serif; font-weight:normal;}
4c79b5
ul.toc {list-style: none}
4c79b5
-->
4c79b5
</style>
4c79b5
4c79b5
4c79b5
</head>
4c79b5
4c79b5
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
4c79b5
4c79b5
aaa0e9
[ < ]
aaa0e9
[ > ]
4c79b5
   
4c79b5
[ << ]
4c79b5
[ Up ]
aaa0e9
[ >> ]
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
[Top]
4c79b5
[Contents]
aaa0e9
[Index]
4c79b5
[ ? ]
4c79b5
aaa0e9
aaa0e9
aaa0e9

3.38 trunk/Scripts/Bash/Functions

aaa0e9
aaa0e9
aaa0e9
aaa0e9

3.38.1 Goals

aaa0e9
aaa0e9

The <tt>`trunk/Scripts/Bash/Functions'</tt> directory exists to organize

aaa0e9
<tt>`centos-art.sh'</tt> specific functionalities.
aaa0e9

aaa0e9
aaa0e9
aaa0e9

3.38.2 Description

aaa0e9
aaa0e9

The specific functions of <tt>`centos-art.sh'</tt> script are designed

aaa0e9
with "Software Toolbox" philosophy (see (coreutils.info)Toolbox introduction) in mind: each program "should do one
aaa0e9
thing well".  Inside <tt>`centos-art.sh'</tt> script, each specific
aaa0e9
functionality is considered a program that should do one thing well.
aaa0e9
Of course, if you find that they still don't do it, feel free to
aaa0e9
improve them in order for them to do so.
aaa0e9

aaa0e9

The specific functions of <tt>`centos-art.sh'</tt> script are organized

aaa0e9
inside specific directories under <tt>`trunk/Scripts/Bash/Functions'</tt>
aaa0e9
location. Each specific function directory should be named as the
aaa0e9
function it represents, with the first letter in uppercase. For
aaa0e9
example, if the function name is render, the specific function
aaa0e9
directory for it would be <samp>`trunk/Scripts/Bash/Functions/Render'</samp>.
aaa0e9

aaa0e9

To better understand how specific functions of <tt>`centos-art.sh'</tt>

aaa0e9
script are designed, lets create one function which only goal is to
aaa0e9
output different kind of greetings to your screen.
aaa0e9

aaa0e9

When we create specific functions for <tt>`centos-art.sh'</tt> script it

aaa0e9
is crucial to know what these functions will do exactly and if there
aaa0e9
is any function that already does what we intend to do. If there is no
aaa0e9
one, it is good time to create them then. Otherwise, if
aaa0e9
functionalities already available don't do what you exactly expect,
aaa0e9
contact their authors and work together to improve them.
aaa0e9

aaa0e9
Info

Tip

Join CentOS developers mailing list

aaa0e9
centos-art@centos.org to share your ideas.
aaa0e9

aaa0e9
aaa0e9

It is also worth to know what global functions and variables do we

aaa0e9
have available inside <tt>`centos-art.sh'</tt> script, so advantage can be
aaa0e9
taken from them. Global variables are defined inside global function
aaa0e9
scripts. Global functions scripts are stored immediatly under
aaa0e9
<tt>`trunk/Scripts/Bash/Functions'</tt> directory, in files begining with
aaa0e9
<samp>`cli'</samp> prefix.
aaa0e9

aaa0e9

OK, let's begin with our functionality example.

aaa0e9

aaa0e9

What function name do we use? Well, lets use greet. Note that

aaa0e9
<samp>`hello'</samp> word is not a verb; but an expression, a kind of
aaa0e9
greeting, an interjection specifically. In contrast, <samp>`greet'</samp> is a
aaa0e9
verb and describes what we do when we say <samp>`Hello!'</samp>, <samp>`Hi!'</samp>,
aaa0e9
and similar expressions.
aaa0e9

aaa0e9

So far, we've gathered the following function information:

aaa0e9

aaa0e9
Name: greet
aaa0e9
Path: trunk/Scripts/Bash/Functions/Greet
aaa0e9
File: trunk/Scripts/Bash/Functions/Greet/greet.sh
aaa0e9
aaa0e9

The <tt>`greet.sh'</tt> function script is the first file

aaa0e9
<tt>`centos-art.sh'</tt> script loads when the <samp>`greet'</samp> functionality
aaa0e9
is called using commands like <samp>`centos-art greet --hello='World''</samp>.
aaa0e9
The <tt>`greet.sh'</tt> function script contains the greet function
aaa0e9
definition. 
aaa0e9

aaa0e9

Inside <tt>`centos-art.sh'</tt> script, as convenction, each function

aaa0e9
script has one top commentary, followed by one blank line, and then
aaa0e9
one function defintion below it only.
aaa0e9

aaa0e9

Inside <tt>`centos-art.sh'</tt> script functions, top commentaries have

aaa0e9
the following components: the functionality description, one-line for
aaa0e9
copyright note with your personal information,  the license under
aaa0e9
which the function source code is released --the <tt>`centos-art.sh'</tt>
aaa0e9
script is released as GPL, so do all its functions--, subversion's
aaa0e9
$Id$ keyword which is later expanded by svn propset
aaa0e9
command.
aaa0e9

aaa0e9

In our greet function example, top commentary for

aaa0e9
<tt>`greet.sh'</tt> function script would look like the following:
aaa0e9

aaa0e9
#!/bin/bash
aaa0e9
#
aaa0e9
# greet.sh -- This function outputs different kind of greetings to
aaa0e9
# your screen. Use this function to understand how centos-art.sh
aaa0e9
# script specific functionalities work.
aaa0e9
#
aaa0e9
# Copyright (C) YEAR YOURFULLNAME
aaa0e9
#
aaa0e9
# This program is free software; you can redistribute it and/or modify
aaa0e9
# it under the terms of the GNU General Public License as published by
aaa0e9
# the Free Software Foundation; either version 2 of the License, or
aaa0e9
# (at your option) any later version.
aaa0e9
# 
aaa0e9
# This program is distributed in the hope that it will be useful, but
aaa0e9
# WITHOUT ANY WARRANTY; without even the implied warranty of
aaa0e9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
aaa0e9
# General Public License for more details.
aaa0e9
#
aaa0e9
# You should have received a copy of the GNU General Public License
aaa0e9
# along with this program; if not, write to the Free Software
aaa0e9
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
aaa0e9
# USA.
aaa0e9
# 
aaa0e9
# ----------------------------------------------------------------------
aaa0e9
# $Id$
aaa0e9
# ----------------------------------------------------------------------
aaa0e9
aaa0e9

After top commentary, separated by one blank line, the greet

aaa0e9
function definition would look like the following:
aaa0e9

aaa0e9
function greet {
aaa0e9
aaa0e9
    # Define global variables.
aaa0e9
aaa0e9
    # Define command-line interface.
aaa0e9
    greet_getActions
aaa0e9
aaa0e9
}
aaa0e9
aaa0e9

The first definition inside greet function, are global

aaa0e9
variables that will be available along greet function execution
aaa0e9
environment. This time we didn't use global variable definitions for
aaa0e9
greet function execution environment, so we left that section
aaa0e9
empty.
aaa0e9

aaa0e9

Later, we call greet_getActions function to define the

aaa0e9
command-line interface of greet functionality. The command-line
aaa0e9
interface of greet functionality defines what and how actions
aaa0e9
are performed, based on arguments combination passed to
aaa0e9
<tt>`centos-art.sh'</tt> script.
aaa0e9

aaa0e9
function greet_getActions {
aaa0e9
aaa0e9
    case "$ACTIONNAM" in
aaa0e9
aaa0e9
        --hello )
aaa0e9
            greet_doHello
aaa0e9
            ;;
aaa0e9
aaa0e9
        --bye )
aaa0e9
            greet_doBye
aaa0e9
            ;;
aaa0e9
aaa0e9
        * )
aaa0e9
            cli_printMessage "`gettext "The option provided is not valid."`"
aaa0e9
            cli_printMessage "$(caller)" 'AsToKnowMoreLine'
aaa0e9
aaa0e9
    esac
aaa0e9
aaa0e9
}
aaa0e9
aaa0e9

The ACTIONNAM global variable is defined in <tt>`cli.sh'</tt>

aaa0e9
function script and contains the value passed before the equal sign
aaa0e9
(i.e., <samp>`='</samp>) in the second command-line argument of
aaa0e9
<tt>`centos-art.sh'</tt> script. For example, if the second command-line
aaa0e9
argument is <samp>`--hello='World''</samp>, the value of ACTIONNAM
aaa0e9
variable would be <samp>`--hello'</samp>.  Using this configuration let us
aaa0e9
deside which action to perform based on the action name passed to
aaa0e9
<tt>`centos-art.sh'</tt> script as second argument. 
aaa0e9

aaa0e9

The greet function definition makes available two valid

aaa0e9
greetings through <samp>`--hello'</samp> and <samp>`--bye'</samp> options.  If no
aaa0e9
one of them is provided as second command-line argument, the <samp>`*'</samp>
aaa0e9
case is evaluated instead. 
aaa0e9

aaa0e9

The <samp>`*'</samp> case and its two lines further on should always be

aaa0e9
present in <tt>`_getActions.sh'</tt> function scripts, no matter what
aaa0e9
specific functionality you are creating. This convenction helps the
aaa0e9
user to find out documentation about current functionality in use,
aaa0e9
when no valid action is provided.
aaa0e9

aaa0e9

The greet_doHello and greet_doBye function definitions

aaa0e9
are the core of greet specific functionality.  In such function
aaa0e9
definitions we set what our greet function really does: to
aaa0e9
output different kinds of greetings.
aaa0e9

aaa0e9
function greet_doHello {
aaa0e9
aaa0e9
    cli_printMessage "`gettext "Hello"` $ACTIONVAL"
aaa0e9
aaa0e9
}
aaa0e9
aaa0e9

The greet_doHello function definition is stored in

aaa0e9
<tt>`greet_doHello.sh'</tt> function script. 
aaa0e9

aaa0e9
function greet_doBye {
aaa0e9
aaa0e9
    cli_printMessage "`gettext "Goodbye"` $ACTIONVAL"
aaa0e9
aaa0e9
}
aaa0e9
aaa0e9

The greet_doBye function definition is stored in the

aaa0e9
<tt>`greet_doBye.sh'</tt> function script. 
aaa0e9

aaa0e9

Both <tt>`greet_doHello.sh'</tt> and <tt>`greet_doBye.sh'</tt> function

aaa0e9
scripts are stored inside greet's function directory path (i.e.
aaa0e9
<tt>`trunk/Scripts/Bash/Functions/Greet'</tt>).
aaa0e9

aaa0e9

The ACTIONVAL global variable is defined in <tt>`cli.sh'</tt>

aaa0e9
function script and contains the value passed after the equal sign
aaa0e9
(i.e., <samp>`='</samp>) in the second command-line argument of
aaa0e9
<tt>`centos-art.sh'</tt> script. For example, if the second command-line
aaa0e9
argument is <samp>`--hello='World''</samp>, the value of ACTIONVAL
aaa0e9
variable would be <samp>`World'</samp> without quotes.
aaa0e9

aaa0e9

Let's see how greet specific functionality files are organzied

aaa0e9
under greet's function directory. To see file organization we
aaa0e9
use the tree command:
aaa0e9

aaa0e9
trunk/Scripts/Bash/Functions/Greet
aaa0e9
|-- greet_doBye.sh
aaa0e9
|-- greet_doHello.sh
aaa0e9
|-- greet_getActions.sh
aaa0e9
`-- greet.sh
aaa0e9
aaa0e9

To try the greet specific functionality we've just created,

aaa0e9
pass the function name (i.e., <samp>`greet'</samp>) as first argument to
aaa0e9
<tt>`centos-art.sh'</tt> script, and any of the valid options as second
aaa0e9
argument. Some examples are illustrated below:
aaa0e9

aaa0e9
[centos@projects ~]$ centos-art greet --hello='World'
aaa0e9
Hello World
aaa0e9
[centos@projects ~]$ centos-art greet --bye='World'
aaa0e9
Goodbye World
aaa0e9
[centos@projects ~]$ 
aaa0e9
aaa0e9

The word <samp>`World'</samp> in the examples above can be anything. In fact,

aaa0e9
change it to have a little fun.
aaa0e9

aaa0e9

Now that we have a specific function that works as we expect, it is

aaa0e9
time to document it.  To document greet specific functionality,
aaa0e9
we use its directory path and the manual functionality
aaa0e9
(see section trunk/Scripts/Bash/Functions/Manual) of <tt>`centos-art.sh'</tt>
aaa0e9
script, just as the following command illustrates: 
aaa0e9

aaa0e9
centos-art manual --edit=trunk/Scripts/Bash/Functions/Greet
aaa0e9
aaa0e9

To have a well documented function helps user to understand how your

aaa0e9
function really works, and how it should be used.  When no valid
aaa0e9
action is passed to a function, the <tt>`centos-art.sh'</tt> script uses
aaa0e9
the function documentation entry as vehicle to communicate which the
aaa0e9
valid functions are. When no documentation entry exists for a
aaa0e9
function, the <tt>`centos-art.sh'</tt> script informs that no
aaa0e9
documentation entry exists for such function and requests user to
aaa0e9
create it right at that time.
aaa0e9

aaa0e9

Now that we have documented our function, it is time to translate its

aaa0e9
output messages to different languages. To translate specific
aaa0e9
functionality output messages to different languages we use the
aaa0e9
locale functionality (see section trunk/Scripts/Bash/Functions/Locale) of <tt>`centos-art.sh'</tt> script, just as the following command
aaa0e9
illustrates:
aaa0e9

aaa0e9
centos-art locale --edit
aaa0e9
aaa0e9
Warning

Warning

To translate output messages in different languages,

aaa0e9
your system locale information --as in LANG environment
aaa0e9
variable-- must be set to that locale you want to produce translated
aaa0e9
messages for. For example, if you want to produce translated messages
aaa0e9
for Spanish language, your system locale information must be set to
aaa0e9
<samp>`es_ES.UTF-8'</samp>, or similar, first.
aaa0e9

aaa0e9
aaa0e9

Well, it seems that our example is rather complete by now.

aaa0e9

aaa0e9

In greet function example we've described so far, we only use

aaa0e9
cli_printMessage global function in action specific function
aaa0e9
definitions in order to print messages, but more interesting things
aaa0e9
can be achieved inside action specific function definitions.  For
aaa0e9
example, if you pass a directory path as action value in second
aaa0e9
argument, you could retrive a list of files from therein, and process
aaa0e9
them. If the list of files turns too long or you just want to control
aaa0e9
which files to process, you could add the third argument in the form
aaa0e9
<samp>`--filter='regex''</samp> and reduce the amount of files to process
aaa0e9
using a regular expression pattern.
aaa0e9

aaa0e9

The greet function described in this section may serve you as

aaa0e9
an introduction to understand how specific functionalities work inside
aaa0e9
<tt>`centos-art.sh'</tt> script. With some of luck this introduction will
aaa0e9
also serve you as motivation to create your own <tt>`centos-art.sh'</tt>
aaa0e9
script specific functionalities.
aaa0e9

aaa0e9

By the way, the greet functionality doesn't exist inside

aaa0e9
<tt>`centos-art.sh'</tt> script yet. Would you like to create it?
aaa0e9

aaa0e9
01b527
aaa0e9

3.38.3 Usage

54264c
54264c
01b527
aaa0e9

3.38.3.1 Global variables

aaa0e9
aaa0e9

The following global variables of <tt>`centos-art.sh'</tt> script, are

aaa0e9
available for you to use inside specific functions:
aaa0e9

aaa0e9
aaa0e9
<u>Variable:</u> TEXTDOMAIN
aaa0e9
aaa0e9
aaa0e9

Default domain used to retrieve translated messages. This value is set

aaa0e9
in <tt>`initFunctions.sh'</tt> and shouldn't be changed.
aaa0e9

aaa0e9
aaa0e9
aaa0e9
<u>Variable:</u> TEXTDOMAINDIR
aaa0e9
aaa0e9
aaa0e9

Default directory used to retrieve translated messages. This value is

aaa0e9
set in <tt>`initFunctions.sh'</tt> and shouldn't be changed.
aaa0e9

aaa0e9
aaa0e9
aaa0e9
<u>Variable:</u> FUNCNAM
aaa0e9
aaa0e9
aaa0e9

Define function name.

aaa0e9

aaa0e9

Function names associate sets of actions. There is one set of actions

aaa0e9
for each unique function name inside <tt>`centos-art.sh'</tt> script.
aaa0e9

aaa0e9

Dunction names are passed as first argument in <tt>`centos-art.sh'</tt>

aaa0e9
command-line interface. For example, in the command <samp>`centos-art
aaa0e9
render --entry=path/to/dir --filter=regex'</samp>, the ACTION passed to
aaa0e9
<tt>`centos-art.sh'</tt> script is <samp>`render'</samp>.
aaa0e9

aaa0e9

When first argument is not provided, the <tt>`centos-art.sh'</tt> script

aaa0e9
immediatly ends its execution.
aaa0e9

aaa0e9
aaa0e9
aaa0e9
<u>Variable:</u> FUNCDIR
aaa0e9
aaa0e9
aaa0e9
aaa0e9
aaa0e9
aaa0e9
<u>Variable:</u> FUNCDIRNAME
aaa0e9
aaa0e9
aaa0e9
aaa0e9
aaa0e9
aaa0e9
<u>Variable:</u> FUNCSCRIPT
aaa0e9
aaa0e9
aaa0e9
280c77
aaa0e9
aaa0e9
<u>Variable:</u> FUNCCONFIG
aaa0e9
aaa0e9
aaa0e9
aaa0e9
aaa0e9
aaa0e9
<u>Variable:</u> ACTIONNAM
aaa0e9
aaa0e9
aaa0e9

Define action name.

aaa0e9

aaa0e9

Each action name identifies an specific action to perform, inside an

aaa0e9
specific function.
aaa0e9

aaa0e9

Action name names aare passed as second argument in

aaa0e9
<tt>`centos-art.sh'</tt> command-line interface. For example, in the
aaa0e9
command <samp>`centos-art render --entry=path/to/dir --filter=regex'</samp>,
aaa0e9
the ACTIONNAM passed to <tt>`centos-art.sh'</tt> script is
aaa0e9
<samp>`--entry'</samp>.
aaa0e9

aaa0e9

When second argument is not provided, the <tt>`centos-art.sh'</tt> script

aaa0e9
immediatly ends its execution.
aaa0e9

aaa0e9
aaa0e9
aaa0e9
<u>Variable:</u> ACTIONVAL
aaa0e9
aaa0e9
aaa0e9

Define action value.

aaa0e9

aaa0e9

Action values are associated to just one action name. Action values

aaa0e9
contain the working copy entry over which its associated action will be
aaa0e9
performed in.  Working copy entries can be files or directories inside
aaa0e9
the working copy.
aaa0e9

aaa0e9
aaa0e9
aaa0e9
<u>Variable:</u> REGEX
aaa0e9
aaa0e9
aaa0e9

Define regular expression used as pattern to build the list of files

aaa0e9
to process.
aaa0e9

aaa0e9

By default, REGEX variable is set to .+ to match all

aaa0e9
files.
aaa0e9

aaa0e9

Functions that need to build a list of files to process use the option

aaa0e9
<samp>`--filter'</samp> to redefine REGEX variable default value, and
aaa0e9
so, control the amount of files to process.
aaa0e9

aaa0e9
aaa0e9
aaa0e9
<u>Variable:</u> ARGUMENTS
aaa0e9
aaa0e9
aaa0e9

Define optional arguments.

aaa0e9

aaa0e9

Optional arguments, inside <tt>`centos-art.sh'</tt> script, are considered

aaa0e9
as all command-line arguments passed to <tt>`centos-art.sh'</tt> script,
aaa0e9
from third argument position on. For example, in the command
aaa0e9
<samp>`centos-art render --entry=path/to/dir --filter=regex'</samp> , the
aaa0e9
optional arguments are from <samp>`--filter=regex'</samp> argument on.
aaa0e9

aaa0e9

Optional arguments are parsed using getopt command through

aaa0e9
the following base construction: 
aaa0e9

aaa0e9
# Define short options we want to support.
aaa0e9
local ARGSS=""
aaa0e9
aaa0e9
# Define long options we want to support.
aaa0e9
local ARGSL="filter:,to:"
aaa0e9
aaa0e9
# Parse arguments using getopt(1) command parser.
aaa0e9
cli_doParseArguments
aaa0e9
aaa0e9
# Reset positional parameters using output from (getopt) argument
aaa0e9
# parser.
aaa0e9
eval set -- "$ARGUMENTS"
aaa0e9
aaa0e9
# Define action to take for each option passed.
aaa0e9
while true; do
aaa0e9
    case "$1" in
aaa0e9
        --filter )
aaa0e9
            REGEX="$2" 
aaa0e9
            shift 2
aaa0e9
            ;;
aaa0e9
        --to )
aaa0e9
            TARGET="$2" 
aaa0e9
            shift 2
aaa0e9
            ;;
aaa0e9
        * )
aaa0e9
            break
aaa0e9
    esac
aaa0e9
done
aaa0e9
aaa0e9

Optional arguments provide support to command options inside

aaa0e9
<tt>`centos-art.sh'</tt> script. For instance, consider the Subversion
aaa0e9
(svn) command, where there are many options (e.g.,
aaa0e9
<samp>`copy'</samp>, <samp>`delete'</samp>, <samp>`move'</samp>, etc), and inside each
aaa0e9
option there are several modifiers (e.g., <samp>`--revision'</samp>,
aaa0e9
<samp>`--message'</samp>, <samp>`--username'</samp>, etc.) that can be combined one
aaa0e9
another in their short or long variants. 
aaa0e9

aaa0e9

The ARGUMENTS variable is used to store arguments passed from

aaa0e9
command-line for later use inside <tt>`centos-art.sh'</tt> script. Storing
aaa0e9
arguments is specially useful when we want to run a command with some
aaa0e9
specific options from them. Consider the following command:
aaa0e9

aaa0e9
centos-art path --copy=SOURCE --to=TARGET --message="The commit message goes here." --username='johndoe'
aaa0e9
aaa0e9

In the above command, the <samp>`--message'</samp>, and <samp>`--username'</samp>

aaa0e9
options are specific to svn copy command. In such cases,
aaa0e9
options are not interpreted by <tt>`centos-art.sh'</tt> script itself.
aaa0e9
Instead, the <tt>`centos-art.sh'</tt> script uses getopt to
aaa0e9
retrive them and store them in the ARGUMENTS variable for later
aaa0e9
use, as described in the following command:
aaa0e9

aaa0e9
# Build subversion command to duplicate locations inside the
aaa0e9
# workstation.
aaa0e9
eval svn copy $SOURCE $TARGET --quiet $ARGUMENTS
aaa0e9
aaa0e9

When getopt parses ARGUMENTS, we may use short options

aaa0e9
(e.g., <samp>`-m'</samp>) or long options (e.g., <samp>`--message'</samp>). When
aaa0e9
we use short options, arguments are separated by one space from the
aaa0e9
option (e.g., <samp>`-m 'This is a commit message.''</samp>).  When we use
aaa0e9
long options arguments are separated by an equal sign (<samp>`='</samp>)
aaa0e9
(e.g., <samp>`--message='This is a commit message''</samp>).
aaa0e9

aaa0e9

In order for getopt to parse ARGUMENTS correctly, it

aaa0e9
is required to provide the short and long definition of options that
aaa0e9
will be passed or at least supported by the command performing the
aaa0e9
final action the function script exists for.
aaa0e9

aaa0e9

As convenction, inside <tt>`centos-art.sh'</tt> script, short option

aaa0e9
definitions are set in the ARGSS variable; and long option
aaa0e9
definitions are set in the ARGSL variable.
aaa0e9

aaa0e9

When you define short and long options, it may be needed to define

aaa0e9
which of these option arguments are required and which not. To define
aaa0e9
an option argument as required, you need to set one colon <samp>`:'</samp>
aaa0e9
after the option definition (e.g., <samp>`-o m: -l message:'</samp>).  On
aaa0e9
the other hand, to define an option argument as not required, you need
aaa0e9
to set two colons <samp>`::'</samp> after the option definition (e.g.,
aaa0e9
<samp>`-o m:: -l message::'</samp>).
aaa0e9

aaa0e9
aaa0e9
aaa0e9
<u>Variable:</u> EDITOR
aaa0e9
aaa0e9
aaa0e9

Default text editor.

aaa0e9

aaa0e9

The <tt>`centos-art.sh'</tt> script uses default text EDITOR to edit

aaa0e9
pre-commit subversion messages, translation files, configuration
aaa0e9
files, script files, and similar text-based files.
aaa0e9

aaa0e9

If EDITOR environment variable is not set, <tt>`centos-art.sh'</tt>

aaa0e9
script uses <tt>`/usr/bin/vim'</tt> as default text editor. Otherwise, the
aaa0e9
following values are recognized by <tt>`centos-art.sh'</tt> script:
aaa0e9

63f275
    aaa0e9
  • <tt>`/usr/bin/vim'</tt>
  • aaa0e9
  • <tt>`/usr/bin/emacs'</tt>
  • aaa0e9
  • <tt>`/usr/bin/nano'</tt>
  • 63f275
    63f275
    aaa0e9

    If no one of these values is set in EDITOR environment variable,

    aaa0e9
    <tt>`centos-art.sh'</tt> uses <tt>`/usr/bin/vim'</tt> text editor by default. 
    aaa0e9

    aaa0e9
    54264c
    01b527
    aaa0e9

    3.38.3.2 Global functions

    280c77
    aaa0e9

    Function scripts stored directly under

    aaa0e9
    <tt>`trunk/Scripts/Bash/Functions/'</tt> directory are used to define
    aaa0e9
    global functions.  Global functions can be used inside action specific
    aaa0e9
    functionalities and or even be reused inside themselves. This section
    aaa0e9
    provides introductory information to global functions you can use
    aaa0e9
    inside <tt>`centos-art.sh'</tt> script.
    aaa0e9

    aaa0e9
    aaa0e9
    <u>Function:</u> cli_checkActionArguments
    aaa0e9
    aaa0e9
    aaa0e9

    Validate action value (ACTIONVAL) variable.

    aaa0e9

    aaa0e9

    The action value variable can take one of the following values:

    aaa0e9

    aaa0e9
      aaa0e9
    1. Path to one directory inside the local working copy,
    2. aaa0e9
    3. Path to one file inside the local working copy,
    4. aaa0e9
      aaa0e9
      aaa0e9

      If another value different from that specified above is passed to

      aaa0e9
      action value variable, the <tt>`centos-art.sh'</tt> script prints an error
      aaa0e9
      message and ends script execution.
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_checkFiles FILE [TYPE]
      aaa0e9
      aaa0e9
      aaa0e9

      Verify file existence.

      aaa0e9

      aaa0e9

      cli_checkFiles receives a FILE absolute path and performs

      aaa0e9
      file verification as specified in TYPE.  When TYPE is not
      aaa0e9
      specified, cli_checkFiles verifies FILE existence, no
      aaa0e9
      matter what kind of file it be.  If TYPE is specified, use one
      aaa0e9
      of the following values:
      aaa0e9

      aaa0e9
      aaa0e9
      <samp>`d'</samp>
      aaa0e9
      <samp>`directory'</samp>
      aaa0e9

      Ends script execution if FILE is not a directory.

      aaa0e9

      aaa0e9

      When you verify directories with cli_checkFiles, if directory doesn't

      aaa0e9
      exist, <tt>`centos-art.sh'</tt> script asks you for confirmation in order
      aaa0e9
      to create that directory. If you answer positively,
      aaa0e9
      <tt>`centos-art.sh'</tt> script creates that directory and continues
      aaa0e9
      script flows normally. Otherwise, if you answer negatively,
      aaa0e9
      <tt>`centos-art.sh'</tt> ends script execution with an error and
      aaa0e9
      documentation message.
      aaa0e9

      aaa0e9
      aaa0e9
      <samp>`f'</samp>
      aaa0e9
      <samp>`regular-file'</samp>
      aaa0e9

      Ends script execution if FILE is not a regular file.

      aaa0e9

      aaa0e9
      <samp>`h'</samp>
      aaa0e9
      <samp>`symbolic-link'</samp>
      aaa0e9

      Ends script execution if FILE is not a symbolic link.

      aaa0e9

      aaa0e9
      <samp>`x'</samp>
      aaa0e9
      <samp>`execution'</samp>
      aaa0e9

      Ends script execution if FILE is not executable.

      aaa0e9

      aaa0e9
      <samp>`fh'</samp>
      aaa0e9

      Ends script execution if FILE is neither a regular file nor a

      aaa0e9
      symbolic link.
      aaa0e9

      aaa0e9
      <samp>`fd'</samp>
      aaa0e9

      Ends script execution if FILE is neither a regular file nor a

      aaa0e9
      directory.
      aaa0e9

      aaa0e9
      <samp>`isInWorkingCopy'</samp>
      aaa0e9

      Ends script execution if FILE is not inside the working copy.

      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9

      As default behaviour, if FILE passes all verifications,

      aaa0e9
      <tt>`centos-art.sh'</tt> script continues with its normal flow. 
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_commitRepoChanges [LOCATION]
      aaa0e9
      aaa0e9
      aaa0e9

      Syncronize changes between repository and working copy.

      aaa0e9

      aaa0e9

      The cli_commitRepoChanges function brings changes from the

      aaa0e9
      central repository down to the working copy--using svn
      aaa0e9
      update--, checks the working copy changes--using svn
      aaa0e9
      status command--, prints status report--using both svn
      aaa0e9
      update and svn status commands output, and finally, commits
      aaa0e9
      recent changes from the working copy up to the repository--using
      aaa0e9
      svn commit command--.
      aaa0e9

      aaa0e9

      Previous to commit the working copy changes up to the central

      aaa0e9
      repository, the cli_commitRepoChanges function asks you to
      aaa0e9
      verify changes--using svn diff command--, and later,
      aaa0e9
      another confirmation question is shown to be sure you really want to
      aaa0e9
      commit changes up to central repository.
      aaa0e9

      aaa0e9

      If LOCATION argument is not specified, the value of

      aaa0e9
      ACTIONVAL variable is used as reference instead.
      aaa0e9

      aaa0e9
      aaa0e9
      ----------------------------------------------------------------------
      aaa0e9
      --> Bringing changes from the repository into the working copy
      aaa0e9
      --> Checking changes in the working copy
      aaa0e9
      ----------------------------------------------------------------------
      aaa0e9
      Added           0 file from the repository.
      aaa0e9
      Deleted         0 file from the repository.
      aaa0e9
      Updated         0 file from the repository.
      aaa0e9
      Conflicted      0 file from the repository.
      aaa0e9
      Merged          0 file from the repository.
      aaa0e9
      Modified        4 files from the working copy.
      aaa0e9
      Unversioned     0 file from the working copy.
      aaa0e9
      Deleted         0 file from the working copy.
      aaa0e9
      Added           0 file from the working copy.
      aaa0e9
      ----------------------------------------------------------------------
      aaa0e9
      aaa0e9

      Figure 3.14: The cli_commitRepoChanges function output.

      aaa0e9
      aaa0e9

      aaa0e9

      Call the cli_commitRepoChanges function before or/and after

      aaa0e9
      calling functions that modify files or directories inside the working
      aaa0e9
      copy as you may need to.  
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_doParseArguments
      aaa0e9
      aaa0e9
      aaa0e9

      Redefine arguments (ARGUMENTS) global variable using

      aaa0e9
      getopt command output. For more information about how to use
      aaa0e9
      cli_doParseArguments function, see ARGUMENTS variable
      aaa0e9
      description above.
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_doParseArgumentsReDef $@
      aaa0e9
      aaa0e9
      aaa0e9

      Initialize/reset arguments (ARGUMENTS) global variable using

      aaa0e9
      positional parameters variable ($@) as reference.
      aaa0e9

      aaa0e9

      When we work inside function definitions, positional parameters are

      aaa0e9
      reset to the last function definition positional parameters.  If you
      aaa0e9
      need to redefine positional parameters from one specific function, you
      aaa0e9
      need to call cli_doParseArgumentsReDef with the positional
      aaa0e9
      parameters variable ($@), set as first argument, to that
      aaa0e9
      specific function you want to redefine positional parameters at.
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getArguments
      aaa0e9
      aaa0e9
      aaa0e9

      Initialize function name (FUNCNAM), action name

      aaa0e9
      (ACTIONNAM), and action value (ACTIONVAL) global
      aaa0e9
      variables, using positional parameters passed in $@ variable.
      aaa0e9

      aaa0e9

      The cli_getArguments function is called from cli.sh

      aaa0e9
      function script, using cli function's positional parameters
      aaa0e9
      (i.e., the positional parameters passed as arguments in the
      aaa0e9
      command-line) as first function argument. 
      aaa0e9

      aaa0e9

      Once command-line positional parameters are accesible to

      aaa0e9
      <tt>`centos-art.sh'</tt> script execution evironment,
      aaa0e9
      cli_getArguments uses regular expression to retrive
      aaa0e9
      action variables from first and second argument. The first argument
      aaa0e9
      defines the value used as function name (FUNCNAM), and the
      aaa0e9
      second argument defines both values used as action name
      aaa0e9
      (ACTIONNAM) and action value (ACTIONVAL), respectively.
      aaa0e9

      aaa0e9

      The first argument is a word in lower case. This word specifies the

      aaa0e9
      name of the functionality you want to use (e.g., <samp>`render'</samp> to
      aaa0e9
      render images, <samp>`manual'</samp> to work on documentation, and so on.)
      aaa0e9

      aaa0e9

      The second argument has a long option style (e.g.,

      aaa0e9
      <samp>`--option=value'</samp>). The <samp>`--option'</samp> represents the action name
      aaa0e9
      (ACTIONNAM), and the characters inbetween the equal sign
      aaa0e9
      (<samp>`='</samp>) and the first space character, are considered as the action
      aaa0e9
      value (ACTIONVAL). In order to provide action values with space
      aaa0e9
      characters inbetween you need to enclose action value with quotes like
      aaa0e9
      in <samp>`--option='This is long value with spaces inbetween''</samp>.
      aaa0e9
      Generally, action values are used to specify paths over which the
      aaa0e9
      action name acts on.
      aaa0e9

      aaa0e9

      Once action related variables (i.e., FUNCNAM, ACTIONNAM,

      aaa0e9
      and ACTIONVAL) are defined and validated,
      aaa0e9
      cli_getArguments shifts the positional arguments to remove the
      aaa0e9
      first two arguments passed (i.e., those used to retrive action related
      aaa0e9
      variables) and redefine the arguments (ARGUMENTS) global
      aaa0e9
      variable with the new positional parameters information.
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getFunctions
      aaa0e9
      aaa0e9
      aaa0e9

      Initialize funtionalities supported by <tt>`centos-art.sh'</tt> script.

      aaa0e9

      aaa0e9

      Functionalities supported by <tt>`centos-art.sh'</tt> script are organized

      aaa0e9
      in functionality directories under
      aaa0e9
      <tt>`trunk/Scripts/Bash/Functions/'</tt> directory. Each functionality
      aaa0e9
      directory stores function scripts to the functionality such directory
      aaa0e9
      was created for. Function scripts contain function definitions.
      aaa0e9
      Function definitions contain several commands focused on achieving one
      aaa0e9
      specific task only (i.e., the one such functionality was created for).
      aaa0e9

      aaa0e9

      In order for <tt>`centos-art.sh'</tt> script to recognize a functionality,

      aaa0e9
      such functionality needs to be stored under
      aaa0e9
      <tt>`trunk/Scripts/Bash/Functions/'</tt> in a directory written
      aaa0e9
      capitalized (i.e., the whole name is written in lowercase except the
      aaa0e9
      first character which is in uppercase). The directory where one
      aaa0e9
      specific functionality is stored is known as the <samp>`functionality
      aaa0e9
      directory'</samp>. 
      aaa0e9

      aaa0e9

      Inside each functionality directory, the functionalty itself is

      aaa0e9
      implemented through function scripts. Function scripts are organized
      aaa0e9
      in files independently one another and written in <samp>`camelCase'</samp>
      aaa0e9
      format with the function name as prefix.  Separation between prefix
      aaa0e9
      and description is done using underscore (<samp>`_'</samp>) character.
      aaa0e9

      aaa0e9

      In order for <tt>`centos-art.sh'</tt> script to load functionalities

      aaa0e9
      correctly, function definition inside function scripts should be set
      aaa0e9
      using the <samp>`function'</samp> reserved word, just as in the following
      aaa0e9
      example:
      aaa0e9

      aaa0e9
      function prefix_doSomething {
      aaa0e9
      aaa0e9
          # Do something here...
      aaa0e9
      aaa0e9
      }
      aaa0e9
      aaa0e9

      The above function definition is just a convenction we use, in order

      aaa0e9
      to make identification of function names easier read and automate by
      aaa0e9
      <tt>`centos-art.sh'</tt> script initialization commands, once
      aaa0e9
      <tt>`centos-art.sh'</tt> script determines which functionality directory
      aaa0e9
      to use.  Specifically, in order to initialize and export functions,
      aaa0e9
      <tt>`centos-art.sh'</tt> script executes all function scripts inside the
      aaa0e9
      functionality directory, and later grep on them using a
      aaa0e9
      regular expression pattern, where the <samp>`function'</samp> reserved word is
      aaa0e9
      used as reference to retrive the function names and export them to
      aaa0e9
      <tt>`centos-art.sh'</tt> script execution environment, and so, make
      aaa0e9
      function definitions --from function scripts inside the functionality
      aaa0e9
      directory-- available for further calls.
      aaa0e9

      aaa0e9

      If the functionality specified in the command-line first argument

      aaa0e9
      doesn't have a functionality directory, <tt>`centos-art.sh'</tt> script
      aaa0e9
      considers the functionality provided in the command-line as invalid
      aaa0e9
      functionality and immediatly stops script execution with an error
      aaa0e9
      message.
      aaa0e9

      aaa0e9

      In order to keep visual consistency among function scripts, please

      aaa0e9
      consider using the following function script design model as template
      aaa0e9
      for your own function scripts:
      aaa0e9

      aaa0e9
      #!/bin/bash
      aaa0e9
      #
      aaa0e9
      # prefix_doSomething.sh -- This function illustrates function scripts
      aaa0e9
      # design model you can use to create your own function scripts inside
      aaa0e9
      # centos-art.sh script.
      aaa0e9
      #
      aaa0e9
      # Copyright (C) YEAR YOURFULLNAME
      aaa0e9
      #
      aaa0e9
      # This program is free software; you can redistribute it and/or modify
      aaa0e9
      # it under the terms of the GNU General Public License as published by
      aaa0e9
      # the Free Software Foundation; either version 2 of the License, or
      aaa0e9
      # (at your option) any later version.
      aaa0e9
      # 
      aaa0e9
      # This program is distributed in the hope that it will be useful, but
      aaa0e9
      # WITHOUT ANY WARRANTY; without even the implied warranty of
      aaa0e9
      # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      aaa0e9
      # General Public License for more details.
      aaa0e9
      #
      aaa0e9
      # You should have received a copy of the GNU General Public License
      aaa0e9
      # along with this program; if not, write to the Free Software
      aaa0e9
      # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
      aaa0e9
      # USA.
      aaa0e9
      # 
      aaa0e9
      # ----------------------------------------------------------------------
      aaa0e9
      # $Id$
      aaa0e9
      # ----------------------------------------------------------------------
      aaa0e9
      aaa0e9
      function prefix_doSomething {
      aaa0e9
      aaa0e9
          # Do something here...
      aaa0e9
      aaa0e9
      }
      aaa0e9
      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getCountryCodes [FILTER]
      aaa0e9
      aaa0e9
      aaa0e9

      Output country codes supported by <tt>`centos-art.sh'</tt> script.

      aaa0e9

      aaa0e9

      The cli_getCountryCodes function outputs a list with country

      aaa0e9
      codes as defined in ISO3166 standard. When FILTER is provided,
      aaa0e9
      cli_getCountryCodes outputs country codes that match
      aaa0e9
      FILTER regular expression pattern.
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getCountryName [FILTER]
      aaa0e9
      aaa0e9
      aaa0e9

      Outputs country name supported by <tt>`centos-art.sh'</tt> script.

      aaa0e9

      aaa0e9

      The cli_getCountryName function reads one language locale code

      aaa0e9
      in the format LL_CC and outputs the name of its related country as in
      aaa0e9
      ISO3166. If filter is specified, cli_getCountryName returns the
      aaa0e9
      country name that matches the locale code specified in FILTER,
      aaa0e9
      exactly.
      aaa0e9

      aaa0e9
       
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getCurrentLocale
      aaa0e9
      aaa0e9
      aaa0e9

      Output current locale used by <tt>`centos-art.sh'</tt> script.

      aaa0e9

      aaa0e9

      The cli_getCurrentLocale function uses LANG environment

      aaa0e9
      variable to build a locale pattern that is later applied to
      aaa0e9
      cli_getLocales function output in order to return the current
      aaa0e9
      locale that <tt>`centos-art.sh'</tt> script works with. 
      aaa0e9

      aaa0e9

      The current locale information, returned by

      aaa0e9
      cli_getCurrentLocale, is output from more specific to less
      aaa0e9
      specific. For example, if <samp>`en_GB'</samp> locale exists in
      aaa0e9
      cli_getLocales function output, the <samp>`en_GB'</samp> locale would
      aaa0e9
      take precedence before <samp>`en'</samp> locale.
      aaa0e9

      aaa0e9

      Locale precedence selection is quite important in order to define the

      aaa0e9
      locale type we use for message translations. For example, if
      aaa0e9
      <samp>`en_GB'</samp> is used, we are also saying that the common language
      aaa0e9
      specification for English language (i.e., <samp>`en'</samp>) is no longer
      aaa0e9
      used. Instead, we are using English non-common country-specific
      aaa0e9
      language specifications like <samp>`en_AU'</samp>, <samp>`en_BW'</samp>, <samp>`en_GB'</samp>,
      aaa0e9
      <samp>`en_US'</samp>, etc., for message translations.  
      aaa0e9

      aaa0e9

      Use cli_getCurrentLocale function to know what current locale

      aaa0e9
      information to use inside <tt>`centos-art.sh'</tt> script.
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getFilesList [LOCATION]
      aaa0e9
      aaa0e9
      aaa0e9

      Output list of files to process.

      aaa0e9

      aaa0e9

      The cli_getFilesList function uses LOCATION variable as

      aaa0e9
      source location to build a list of files just as specified by regular
      aaa0e9
      expression (REGEX) global variable. Essentially, what the
      aaa0e9
      cli_getFilesList function does is using find command
      aaa0e9
      to look for files in the location (LOCATION) just as posix-egrep
      aaa0e9
      regular expression (REGEX) specifies. 
      aaa0e9

      aaa0e9

      If LOCATION is not specified when cli_getFilesList

      aaa0e9
      function is called, the action value (ACTIONVAL) global variable
      aaa0e9
      is used as location value instead.
      aaa0e9

      aaa0e9

      By default, if the regular expression (REGEX) global variable is

      aaa0e9
      not redefined after its first definition in the cli function,
      aaa0e9
      all files that match default regular expression value (i.e.,
      aaa0e9
      <samp>`.+'</samp>) will be added to the list of files to process. Otherwise,
      aaa0e9
      if you redefine the regular expression global variable after its first
      aaa0e9
      definition in the cli function and before calling
      aaa0e9
      cli_getFilesList function, the last value you specifed is used
      aaa0e9
      instead.
      aaa0e9

      aaa0e9

      When you need to customize the regular expression (REGEX) global

      aaa0e9
      variable value inside a function, do not redefine the global variable
      aaa0e9
      (at least you be absolutly convinced you need to).  Instead, set the
      aaa0e9
      regular expression global variable as <samp>`local'</samp> to the function you
      aaa0e9
      need a customized regular expression value for.  If we don't redefine
      aaa0e9
      the regular expression global variable as local to the function, or
      aaa0e9
      use another name for the regular expression variable (which is not
      aaa0e9
      very convenient in order to keep the amount of names to remember low),
      aaa0e9
      you may experiment undesired concantenation issues that make your
      aaa0e9
      regular expression to be something different from that you expect them
      aaa0e9
      to be, specially if the function where you are doing the variable
      aaa0e9
      redefinition is called several times during the same script execution.
      aaa0e9

      aaa0e9

      As result, the cli_getFilesList re-defines the value of

      aaa0e9
      FILES variable with the list of files the find command
      aaa0e9
      returned. As example, consider the following construction:
      aaa0e9

      aaa0e9
      function prefix_doSomething {
      aaa0e9
      aaa0e9
          # Initialize the list of files to process.
      aaa0e9
          local FILES=''
      aaa0e9
      aaa0e9
          # Initialize location.
      aaa0e9
          local LOCATION=/home/centos/artwork/trunk/Identity/Themes/Models/Default
      aaa0e9
      aaa0e9
          # Re-define regular expression to match scalable vector graphic
      aaa0e9
          # files only. Note how we use the global value of REGEX to build a
      aaa0e9
          # new local REGEX value here.
      aaa0e9
          local REGEX="${REGEX}.*\.(svgz|svg)"
      aaa0e9
      aaa0e9
          # Redefine list of files to process.
      aaa0e9
          cli_getFilesList $LOCATION
      aaa0e9
      aaa0e9
          # Process list of files.
      aaa0e9
          for FILE in $FILES;do
      aaa0e9
              cli_printMessages "$FILE" 'AsResponseLine'
      aaa0e9
              # Do something else here on...
      aaa0e9
          done
      aaa0e9
      aaa0e9
      }
      aaa0e9
      aaa0e9
      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getLangCodes [FILTER]
      aaa0e9
      aaa0e9
      aaa0e9

      Outputs language codes supported by <tt>`centos-art.sh'</tt> script.

      aaa0e9

      aaa0e9

      cli_getLangCodes function outputs a list of language codes as

      aaa0e9
      defined in ISO639 standard. When FILTER is provided,
      aaa0e9
      cli_getLangCodes outputs language codes that match FILTER
      aaa0e9
      regular expression pattern.
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getLangName [FILTER]
      aaa0e9
      aaa0e9
      aaa0e9

      Outputs language names supported by <tt>`centos-art.sh'</tt> script.

      aaa0e9

      aaa0e9

      cli_getLangName function reads one language locale code in the

      aaa0e9
      format LL_CC and outputs the language related name as in ISO639. If
      aaa0e9
      filter is specified, cli_getLangName returns the language name
      aaa0e9
      that matches the locale code specified in FILTER, exactly.
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getLocales
      aaa0e9
      aaa0e9
      aaa0e9

      Output locale codes supported by <tt>`centos-art.sh'</tt> script.

      aaa0e9

      aaa0e9

      Occasionally, you use cli_getLocales function to add locale

      aaa0e9
      information in non-common country-specific language (<samp>`LL_CC'</samp>)
      aaa0e9
      format for those languages (e.g., <samp>`bn_IN'</samp>, <samp>`pt_BR'</samp>, etc.)
      aaa0e9
      which locale differences cannot be solved using common language
      aaa0e9
      specifications (<samp>`LL'</samp>) into one unique common locale specification
      aaa0e9
      (e.g., <samp>`bn'</samp>, <samp>`pt'</samp>, etc.).  
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getRepoName NAME TYPE
      aaa0e9
      aaa0e9
      aaa0e9

      Sanitate file names.

      aaa0e9

      aaa0e9

      Inside <tt>`centos-art.sh'</tt> script, specific functionalities rely both

      aaa0e9
      in cli_getRepoName and repository file system organization to
      aaa0e9
      achieve their goals.  Consider cli_getRepoName function as
      aaa0e9
      central place to manage file name convenctions for other functions
      aaa0e9
      inside <tt>`centos-art.sh'</tt> script.
      aaa0e9

      aaa0e9
      Important

      Important

      cli_getRepoName function doesn't verify file

      aaa0e9
      or directory existence, for that purpose use cli_checkFiles
      aaa0e9
      function instead.
      aaa0e9

      aaa0e9
      aaa0e9

      The NAME variable contains the file name or directory name you

      aaa0e9
      want to sanitate.
      aaa0e9

      aaa0e9

      The TYPE variable specifies what type of sanitation you want to

      aaa0e9
      perform on NAME. The TYPE can be one of the following
      aaa0e9
      values:
      aaa0e9

      aaa0e9
      aaa0e9
      <samp>`d'</samp>
      aaa0e9
      <samp>`directory'</samp>
      aaa0e9

      Sanitate directory NAMEs.

      aaa0e9

      aaa0e9
      <samp>`f'</samp>
      aaa0e9
      <samp>`regular-file'</samp>
      aaa0e9

      Sanitate regular file NAMEs.

      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9

      Use cli_getRepoName function to sanitate file names and

      aaa0e9
      directory names before their utilization. 
      aaa0e9

      aaa0e9

      Use cli_getRepoName when you need to change file name

      aaa0e9
      convenctions inside <tt>`centos-art.sh'</tt> script. 
      aaa0e9

      aaa0e9

      When we change file name convenctions inside cli_getRepoName

      aaa0e9
      what we are really changing is the way functions interpret repository
      aaa0e9
      file system organization. Notice that when we change a file name
      aaa0e9
      (e.g., a function name), it is necessary to update all files where
      aaa0e9
      such file name is placed on. This may require a massive substitution
      aaa0e9
      inside the repository, each time we change name convenctions in the
      aaa0e9
      repository (see section trunk/Scripts/Bash/Functions/Path, for more
      aaa0e9
      information).
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getRepoStatus [LOCATION]
      aaa0e9
      aaa0e9
      aaa0e9

      Request repository status.

      aaa0e9

      aaa0e9

      This function requests the status of a LOCATION inside the

      aaa0e9
      working copy using the svn status command and returns the
      aaa0e9
      first character in the output line, just as described in svn
      aaa0e9
      help status. If LOCATION is not a regular file or a directory,
      aaa0e9
      inside the working copy, the <tt>`centos-art.sh'</tt> script prints a
      aaa0e9
      message and ends its execution.
      aaa0e9

      aaa0e9

      Use this function to perform verifications based a repository

      aaa0e9
      LOCATION status.
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getTemporalFile NAME
      aaa0e9
      aaa0e9
      aaa0e9

      Output absolute path to temporal file NAME.

      aaa0e9

      aaa0e9

      The cli_getTemporalFile function uses <tt>`/tmp'</tt> directory as

      aaa0e9
      source location to store temporal files, the <tt>`centos-art.sh'</tt>
      aaa0e9
      script name, and a random identification string to let you run more
      aaa0e9
      than one <tt>`centos-art.sh'</tt> script simultaneously on the same user
      aaa0e9
      session.  For example, due the following temporal file defintion:
      aaa0e9

      aaa0e9
      cli_getTemporalFile $FILE
      aaa0e9
      aaa0e9

      If FILE name is <tt>`instance.svg'</tt> and the unique random string

      aaa0e9
      is <samp>`f16f7b51-ac12-4b7f-9e66-72df847f12de'</samp>, the final temporal
      aaa0e9
      file, built from previous temporal file definition, would be:
      aaa0e9

      aaa0e9
      /tmp/centos-art.sh-f16f7b51-ac12-4b7f-9e66-72df847f12de-instance.svg
      aaa0e9
      aaa0e9

      When you use the cli_getTemporalFile function to create

      aaa0e9
      temporal files, be sure to remove temporal files created once you've
      aaa0e9
      ended up with them.  For example, consider the following construction:
      aaa0e9

      aaa0e9
      for FILE in $FILES;do
      aaa0e9
      aaa0e9
          # Initialize temporal instance of file.
      aaa0e9
          INSTANCE=$(cli_getTemporalFile $FILE)
      aaa0e9
      aaa0e9
          # Do something ... 
      aaa0e9
      aaa0e9
          # Remove temporal instance of file.
      aaa0e9
          if [[ -f $INSTANCE ]];then
      aaa0e9
              rm $INSTANCE
      aaa0e9
          fi
      aaa0e9
      aaa0e9
      done
      aaa0e9
      aaa0e9

      Use the cli_getTemporalFile function whenever you need to

      aaa0e9
      create temporal files inside <tt>`centos-art.sh'</tt> script.
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_getThemeName
      aaa0e9
      aaa0e9
      aaa0e9

      Output theme name.

      aaa0e9

      aaa0e9

      In order for cli_getThemeName function to extract theme name

      aaa0e9
      correctly, the ACTIONVAL variable must contain a directory path
      aaa0e9
      under <tt>`trunk/Identity/Themes/Motifs/'</tt> directory structure.
      aaa0e9
      Otherwise, cli_getThemeName returns an empty string.  
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9
      <u>Function:</u> cli_printMessage MESSAGE [FORMAT]
      aaa0e9
      aaa0e9
      aaa0e9

      Define standard output message definition supported by

      aaa0e9
      <tt>`centos-art.sh'</tt> script.
      aaa0e9

      aaa0e9

      When FORMAT is not specified, cli_printMessage outputs

      aaa0e9
      information just as it was passed in MESSAGE variable.
      aaa0e9
      Otherwise, FORMAT can take one of the following values:
      aaa0e9

      aaa0e9
      aaa0e9
      <samp>`AsHeadingLine'</samp>
      aaa0e9

      To print heading messages.

      aaa0e9

      ----------------------------------------------------------------------
      aaa0e9
      $MESSAGE
      aaa0e9
      ----------------------------------------------------------------------
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsWarningLine'</samp>
      aaa0e9

      To print warning messages.

      aaa0e9

      ----------------------------------------------------------------------
      aaa0e9
      WARNING: $MESSAGE
      aaa0e9
      ----------------------------------------------------------------------
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsNoteLine'</samp>
      aaa0e9

      To print note messages.

      aaa0e9

      ----------------------------------------------------------------------
      aaa0e9
      NOTE: $MESSAGE
      aaa0e9
      ----------------------------------------------------------------------
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsUpdatingLine'</samp>
      aaa0e9

      To print <samp>`Updating'</samp> messages on two-columns format.

      aaa0e9

      Updating        $MESSAGE
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsRemovingLine'</samp>
      aaa0e9

      To print <samp>`Removing'</samp> messages on two-columns format.

      aaa0e9

      Removing        $MESSAGE
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsCheckingLine'</samp>
      aaa0e9

      To print <samp>`Checking'</samp> messages on two-columns format.

      aaa0e9

      Checking        $MESSAGE
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsCreatingLine'</samp>
      aaa0e9

      To print <samp>`Creating'</samp> messages on two-columns format.

      aaa0e9

      Creating        $MESSAGE
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsSavedAsLine'</samp>
      aaa0e9

      To print <samp>`Saved as'</samp> messages on two-columns format.

      aaa0e9

      Saved as        $MESSAGE
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsLinkToLine'</samp>
      aaa0e9

      To print <samp>`Linked to'</samp> messages on two-columns format.

      aaa0e9

      Linked to       $MESSAGE
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsMovedToLine'</samp>
      aaa0e9

      To print <samp>`Moved to'</samp> messages on two-columns format.

      aaa0e9

      Moved to        $MESSAGE
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsTranslationLine'</samp>
      aaa0e9

      To print <samp>`Translation'</samp> messages on two-columns format.

      aaa0e9

      Translation     $MESSAGE
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsConfigurationLine'</samp>
      aaa0e9

      To print <samp>`Configuration'</samp> messages on two-columns format.

      aaa0e9

      Configuration   $MESSAGE
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsResponseLine'</samp>
      aaa0e9

      To print response messages on one-column format.

      aaa0e9

      --> $MESSAGE
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsRequestLine'</samp>
      aaa0e9

      To print request messages on one-column format. Request messages

      aaa0e9
      output messages with one colon (<samp>`:'</samp>) and without trailing newline
      aaa0e9
      (<samp>`\n'</samp>) at message end.
      aaa0e9

      $MESSAGE:
      aaa0e9
      aaa0e9
      aaa0e9
      <samp>`AsYesOrNoRequestLine'</samp>
      aaa0e9

      To print <samp>`yes or no'</samp> request messages on one-column format. If

      aaa0e9
      something different from <samp>`y'</samp> is answered (when using
      aaa0e9
      en_US.UTF-8 locale), script execution ends immediatly.  
      aaa0e9

      aaa0e9
      $MESSAGE [y/N]:
      aaa0e9
      aaa0e9

      When we use <tt>`centos-art.sh'</tt> script in a locale different from

      aaa0e9
      en_US.UTF-8, confirmation answer may be different from
      aaa0e9
      <samp>`y'</samp>. For example, if you use es_ES.UTF-8 locale, the
      aaa0e9
      confirmation question would look like:
      aaa0e9

      aaa0e9
      $MESSAGE [s/N]:
      aaa0e9
      aaa0e9

      and the confirmation answer would be <samp>`s'</samp>, as it is on Spanish

      aaa0e9
      <samp>`sí'</samp> word.
      aaa0e9

      aaa0e9

      Definition of which confirmation word to use is set on translation

      aaa0e9
      messages for your specific locale information. See section trunk/Scripts/Bash/Functions/Locale, for more information about locale-specific
      aaa0e9
      translation messages.
      aaa0e9

      aaa0e9
      aaa0e9
      <samp>`AsToKnowMoreLine'</samp>
      aaa0e9

      To standardize <samp>`to know more, run the following command:'</samp>

      aaa0e9
      messages. When the <samp>`AsToKnowMoreLine'</samp> option is used, the
      aaa0e9
      MESSAGE value should be set to "$(caller)". caller
      aaa0e9
      is a Bash builtin that returns the context of the current subroutine
      aaa0e9
      call. <samp>`AsToKnowMoreLine'</samp> option uses caller builtin
      aaa0e9
      output to build documentation entries dynamically.
      aaa0e9

      aaa0e9
      ----------------------------------------------------------------------
      aaa0e9
      To know more, run the following command:
      aaa0e9
      centos-art manual --read='path/to/dir'
      aaa0e9
      ----------------------------------------------------------------------
      aaa0e9
      aaa0e9

      Use <samp>`AsToKnowMoreLine'</samp> option after errors and for intentional

      aaa0e9
      script termination. 
      aaa0e9

      aaa0e9
      aaa0e9
      <samp>`AsRegularLine'</samp>
      aaa0e9

      To standardize regular messages on one-column format.

      aaa0e9

      aaa0e9

      When MESSAGE contains a colon inside (e.g., <samp>`description:

      aaa0e9
      message'</samp>), the cli_printMessage function outputs MESSAGE
      aaa0e9
      on two-columns format. 
      aaa0e9

      aaa0e9
      aaa0e9
      aaa0e9

      Use cli_printMessage function whenever you need to output

      aaa0e9
      information from <tt>`centos-art.sh'</tt> script.
      aaa0e9

      aaa0e9
      Info

      Tip

      To improve two-columns format, change the following file:

      aaa0e9

      trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
      aaa0e9
      aaa0e9
      63f275
      63f275
      01b527
      aaa0e9

      3.38.3.3 Specific functions

      54264c
      aaa0e9

      The following specific functions of <tt>`centos-art.sh'</tt> script, are

      aaa0e9
      available for you to use:
      aaa0e9

      aaa0e9
      aaa0e9
      3.39 trunk/Scripts/Bash/Functions/Html  
      aaa0e9
      aaa0e9
      3.40 trunk/Scripts/Bash/Functions/Locale  
      aaa0e9
      aaa0e9
      3.41 trunk/Scripts/Bash/Functions/Manual  
      aaa0e9
      aaa0e9
      3.42 trunk/Scripts/Bash/Functions/Path  
      aaa0e9
      aaa0e9
      3.43 trunk/Scripts/Bash/Functions/Render  
      aaa0e9
      aaa0e9
      3.44 trunk/Scripts/Bash/Functions/Render/Config  
      aaa0e9
      aaa0e9
      3.45 trunk/Scripts/Bash/Functions/Shell  
      aaa0e9
      aaa0e9
      3.46 trunk/Scripts/Bash/Functions/Svg  
      aaa0e9
      aaa0e9
      3.47 trunk/Scripts/Bash/Functions/Verify  
      aaa0e9
      aaa0e9
      54264c
      63f275
      01b527
      54264c

      3.38.4 See also

      4c79b5
      aaa0e9
      aaa0e9
      3.37 trunk/Scripts/Bash  
      aaa0e9
      aaa0e9
      3.48 trunk/Scripts/Bash/Locale  
      aaa0e9
      aaa0e9
      4c79b5
      6ba043
      4c79b5
      01b527
      [ < ]
      01b527
      [ > ]
      4c79b5
         
      4c79b5
      [ << ]
      aaa0e9
      [ Up ]
      aaa0e9
      [ >> ]
      4c79b5
      4c79b5

      4c79b5
       <font size="-1">
      92fb7f
        This document was generated on January, 5 2011 using texi2html 1.76.
      4c79b5
       </font>
      4c79b5
       
      4c79b5
      4c79b5

      4c79b5
      </body>
      4c79b5
      </html>