Blame Manuals/Repository/repository-html/repository_52.html

4c79b5
4c79b5
<html>
ccb7a3
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
-->
acd47b
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>
c2a1bc
<title>CentOS Artwork Repository: 3.49 trunk/Scripts/Bash/Functions</title>
4c79b5
c2a1bc
<meta name="description" content="CentOS Artwork Repository: 3.49 trunk/Scripts/Bash/Functions">
c2a1bc
<meta name="keywords" content="CentOS Artwork Repository: 3.49 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
2dc146
[ < ]
2dc146
[ > ]
4c79b5
   
4c79b5
[ << ]
4c79b5
[ Up ]
c2a1bc
[ >> ]
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
[Top]
4c79b5
[Contents]
c2a1bc
[Index]
4c79b5
[ ? ]
4c79b5
c2a1bc
2dc146
c2a1bc

3.49 trunk/Scripts/Bash/Functions

2dc146
2dc146
2dc146
2dc146

3.49.1 Goals

2dc146
c2a1bc

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

c2a1bc
<tt>`centos-art.sh'</tt> specific functionalities.
2dc146

2dc146
2dc146
2dc146

3.49.2 Description

2dc146
c2a1bc

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

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

c2a1bc

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

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

c2a1bc

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

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

c2a1bc

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

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

c2a1bc
Info

Tip

Join CentOS developers mailing list

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

c2a1bc
c2a1bc

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

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

c2a1bc

OK, let's begin with our functionality example.

c2a1bc

c2a1bc

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

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

c2a1bc

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

c2a1bc

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

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

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

c2a1bc

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

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

c2a1bc

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

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

c2a1bc

In our greet function example, top commentary for

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

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

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

c2a1bc
function definition would look like the following:
c2a1bc

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

The first definition inside greet function, are global

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

c2a1bc

Later, we call greet_getActions function to define the

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

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

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

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

c2a1bc

The greet function definition makes available two valid

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

c2a1bc

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

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

c2a1bc

The greet_doHello and greet_doBye function definitions

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

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

The greet_doHello function definition is stored in

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

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

The greet_doBye function definition is stored in the

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

c2a1bc

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

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

c2a1bc

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

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

c2a1bc

Let's see how greet specific functionality files are organzied

c2a1bc
under greet function directory. To see file organization we use
c2a1bc
the tree command:
c2a1bc

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

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

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

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

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

c2a1bc
change it to have a little fun.
c2a1bc

c2a1bc

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

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

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

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

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

c2a1bc

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

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

c2a1bc
centos-art locale --edit
c2a1bc
c2a1bc
Warning

Warning

To translate output messages in different languages,

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

c2a1bc
c2a1bc

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

c2a1bc

c2a1bc

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

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

c2a1bc

The greet function described in this section may serve you as

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

c2a1bc

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

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

2dc146
4a9d2a
2dc146

3.49.3 Usage

008ee0
2b5e61
7fa1fb
c2a1bc

3.49.3.1 Global variables

c2a1bc
c2a1bc

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

c2a1bc
available for you to use inside specific functions:
c2a1bc

c2a1bc
c2a1bc
<u>Variable:</u> TEXTDOMAIN
c2a1bc
c2a1bc
c2a1bc

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

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

c2a1bc
c2a1bc
c2a1bc
<u>Variable:</u> TEXTDOMAINDIR
c2a1bc
c2a1bc
c2a1bc

Default directory used to retrieve translated messages. This value is

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

2b5e61
c2a1bc
c2a1bc
<u>Variable:</u> FUNCNAM
c2a1bc
c2a1bc
c2a1bc

Define function name.

c2a1bc

c2a1bc

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

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

c2a1bc

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

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

c2a1bc

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

c2a1bc
immediatly ends its execution.
c2a1bc

c2a1bc
c2a1bc
c2a1bc
<u>Variable:</u> FUNCDIR
c2a1bc
c2a1bc
c2a1bc
c2a1bc
c2a1bc
c2a1bc
<u>Variable:</u> FUNCDIRNAME
c2a1bc
c2a1bc
c2a1bc
c2a1bc
c2a1bc
c2a1bc
<u>Variable:</u> FUNCSCRIPT
c2a1bc
c2a1bc
c2a1bc
c2a1bc
c2a1bc
c2a1bc
<u>Variable:</u> FUNCCONFIG
c2a1bc
c2a1bc
c2a1bc
c2a1bc
c2a1bc
c2a1bc
<u>Variable:</u> ACTIONNAM
c2a1bc
c2a1bc
c2a1bc

Define action name.

c2a1bc

c2a1bc

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

c2a1bc
specific function.
c2a1bc

c2a1bc

Action name names aare passed as second argument in

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

c2a1bc

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

c2a1bc
immediatly ends its execution.
c2a1bc

c2a1bc
c2a1bc
c2a1bc
<u>Variable:</u> ACTIONVAL
c2a1bc
c2a1bc
c2a1bc

Define action value.

c2a1bc

c2a1bc

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

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

c2a1bc
c2a1bc
c2a1bc
<u>Variable:</u> REGEX
c2a1bc
c2a1bc
c2a1bc

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

c2a1bc
to process.
c2a1bc

c2a1bc

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

c2a1bc
files.
c2a1bc

c2a1bc

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

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

c2a1bc
c2a1bc
c2a1bc
<u>Variable:</u> ARGUMENTS
c2a1bc
c2a1bc
c2a1bc

Define optional arguments.

c2a1bc

c2a1bc

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

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

c2a1bc

Optional arguments are parsed using getopt command through

c2a1bc
the following base construction: 
c2a1bc

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

Optional arguments provide support to command options inside

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

c2a1bc

The ARGUMENTS variable is used to store arguments passed from

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

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

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

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

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

When getopt parses ARGUMENTS, we may use short options

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

c2a1bc

In order for getopt to parse ARGUMENTS correctly, it

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

c2a1bc

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

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

c2a1bc

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

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

c2a1bc
c2a1bc
c2a1bc
<u>Variable:</u> EDITOR
c2a1bc
c2a1bc
c2a1bc

Default text editor.

c2a1bc

c2a1bc

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

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

c2a1bc

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

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

c2a1bc
    c2a1bc
  • <tt>`/usr/bin/vim'</tt>
  • c2a1bc
  • <tt>`/usr/bin/emacs'</tt>
  • c2a1bc
  • <tt>`/usr/bin/nano'</tt>
  • c2a1bc
    c2a1bc
    c2a1bc

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

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

    c2a1bc
    c2a1bc
    c2a1bc
    c2a1bc

    3.49.3.2 Global functions

    c2a1bc
    c2a1bc

    Function scripts stored directly under

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

    c2a1bc
    c2a1bc
    <u>Function:</u> cli_checkActionArguments
    c2a1bc
    c2a1bc
    c2a1bc

    Validate action value (ACTIONVAL) variable.

    c2a1bc

    c2a1bc

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

    c2a1bc

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

      If another value different from that specified above is passed to

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

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

      Verify file existence.

      c2a1bc

      c2a1bc

      cli_checkFiles receives a FILE absolute path and performs

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

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

      Ends script execution if FILE is not a directory.

      c2a1bc

      c2a1bc

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

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

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

      Ends script execution if FILE is not a regular file.

      c2a1bc

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

      Ends script execution if FILE is not a symbolic link.

      c2a1bc

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

      Ends script execution if FILE is not executable.

      c2a1bc

      c2a1bc
      <samp>`fh'</samp>
      c2a1bc

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

      c2a1bc
      symbolic link.
      c2a1bc

      c2a1bc
      <samp>`fd'</samp>
      c2a1bc

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

      c2a1bc
      directory.
      c2a1bc

      c2a1bc
      <samp>`isInWorkingCopy'</samp>
      c2a1bc

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

      c2a1bc

      c2a1bc
      c2a1bc
      c2a1bc

      As default behaviour, if FILE passes all verifications,

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

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

      Syncronize changes between repository and working copy.

      c2a1bc

      c2a1bc

      The cli_commitRepoChanges function brings changes from the

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

      c2a1bc

      Previous to commit the working copy changes up to the central

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

      c2a1bc

      If LOCATION argument is not specified, the value of

      c2a1bc
      ACTIONVAL variable is used as reference instead.
      c2a1bc

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

      Figure 3.3: The cli_commitRepoChanges function output.

      c2a1bc
      c2a1bc

      c2a1bc

      Call the cli_commitRepoChanges function before or/and after

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

      c2a1bc
      c2a1bc
      c2a1bc
      <u>Function:</u> cli_doParseArguments
      c2a1bc
      c2a1bc
      c2a1bc

      Redefine arguments (ARGUMENTS) global variable using

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

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

      Initialize/reset arguments (ARGUMENTS) global variable using

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

      c2a1bc

      When we work inside function definitions, positional parameters are

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

      c2a1bc
      c2a1bc
      c2a1bc
      <u>Function:</u> cli_getArguments
      c2a1bc
      c2a1bc
      c2a1bc

      Initialize function name (FUNCNAM), action name

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

      c2a1bc

      The cli_getArguments function is called from cli.sh

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

      c2a1bc

      Once command-line positional parameters are accesible to

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

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc
      c2a1bc
      c2a1bc
      <u>Function:</u> cli_getFunctions
      c2a1bc
      c2a1bc
      c2a1bc

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

      c2a1bc

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

      Inside each functionality directory, the functionalty itself is

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

      c2a1bc

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

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

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

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

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

      c2a1bc

      If the functionality specified in the command-line first argument

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

      c2a1bc

      In order to keep visual consistency among function scripts, please

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

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

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

      c2a1bc

      c2a1bc

      The cli_getCountryCodes function outputs a list with country

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

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

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

      c2a1bc

      c2a1bc

      The cli_getCountryName function reads one language locale code

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

      c2a1bc
       
      c2a1bc
      c2a1bc
      <u>Function:</u> cli_getCurrentLocale
      c2a1bc
      c2a1bc
      c2a1bc

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

      c2a1bc

      c2a1bc

      The cli_getCurrentLocale function uses LANG environment

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

      c2a1bc

      The current locale information, returned by

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

      c2a1bc

      Locale precedence selection is quite important in order to define the

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

      c2a1bc

      Use cli_getCurrentLocale function to know what current locale

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

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

      Output list of files to process.

      c2a1bc

      c2a1bc

      The cli_getFilesList function uses LOCATION variable as

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

      c2a1bc

      If LOCATION is not specified when cli_getFilesList

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

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

      As result, the cli_getFilesList re-defines the value of

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

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

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

      c2a1bc

      c2a1bc

      cli_getLangCodes function outputs a list of language codes as

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

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

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

      c2a1bc

      c2a1bc

      cli_getLangName function reads one language locale code in the

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

      c2a1bc
      c2a1bc
      c2a1bc
      <u>Function:</u> cli_getLocales
      c2a1bc
      c2a1bc
      c2a1bc

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

      c2a1bc

      c2a1bc

      Occasionally, you use cli_getLocales function to add locale

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

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

      Sanitate file names.

      c2a1bc

      c2a1bc

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

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

      c2a1bc
      Important

      Important

      cli_getRepoName function doesn't verify file

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

      c2a1bc
      c2a1bc

      The NAME variable contains the file name or directory name you

      c2a1bc
      want to sanitate.
      c2a1bc

      c2a1bc

      The TYPE variable specifies what type of sanitation you want to

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

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

      Sanitate directory NAMEs.

      c2a1bc

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

      Sanitate regular file NAMEs.

      c2a1bc

      c2a1bc
      c2a1bc
      c2a1bc

      Use cli_getRepoName function to sanitate file names and

      c2a1bc
      directory names before their utilization. 
      c2a1bc

      c2a1bc

      Use cli_getRepoName when you need to change file name

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

      c2a1bc

      When we change file name convenctions inside cli_getRepoName

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

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

      Request repository status.

      c2a1bc

      c2a1bc

      This function requests the status of a LOCATION inside the

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

      c2a1bc

      Use this function to perform verifications based a repository

      c2a1bc
      LOCATION status.
      c2a1bc

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

      Output absolute path to temporal file NAME.

      c2a1bc

      c2a1bc

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

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

      c2a1bc
      cli_getTemporalFile $FILE
      c2a1bc
      c2a1bc

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

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

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

      When you use the cli_getTemporalFile function to create

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

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

      Use the cli_getTemporalFile function whenever you need to

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

      c2a1bc
      c2a1bc
      c2a1bc
      <u>Function:</u> cli_getThemeName
      c2a1bc
      c2a1bc
      c2a1bc

      Output theme name.

      c2a1bc

      c2a1bc

      In order for cli_getThemeName function to extract theme name

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

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

      Define standard output message definition supported by

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

      c2a1bc

      When FORMAT is not specified, cli_printMessage outputs

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

      c2a1bc
      c2a1bc
      <samp>`AsHeadingLine'</samp>
      c2a1bc

      To print heading messages.

      c2a1bc

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

      To print warning messages.

      c2a1bc

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

      To print note messages.

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

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

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

      c2a1bc

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

      To print response messages on one-column format.

      c2a1bc

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

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

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

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

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

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

      c2a1bc
      $MESSAGE [y/N]:
      c2a1bc
      c2a1bc

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

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

      c2a1bc
      $MESSAGE [s/N]:
      c2a1bc
      c2a1bc

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

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

      c2a1bc

      Definition of which confirmation word to use is set on translation

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

      c2a1bc
      c2a1bc
      <samp>`AsToKnowMoreLine'</samp>
      c2a1bc

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

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

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

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

      c2a1bc
      script termination. 
      c2a1bc

      c2a1bc
      c2a1bc
      <samp>`AsRegularLine'</samp>
      c2a1bc

      To standardize regular messages on one-column format.

      c2a1bc

      c2a1bc

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

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

      c2a1bc
      c2a1bc
      c2a1bc

      Use cli_printMessage function whenever you need to output

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

      c2a1bc
      Info

      Tip

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

      c2a1bc

      trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
      c2a1bc
      c2a1bc
      c2a1bc
      c2a1bc
      c2a1bc
      c2a1bc

      3.49.3.3 Specific functions

      c2a1bc
      c2a1bc

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

      c2a1bc
      available for you to use:
      c2a1bc

      2b5e61
      c2a1bc
      3.50 trunk/Scripts/Bash/Functions/Html  
      c2a1bc
      c2a1bc
      3.51 trunk/Scripts/Bash/Functions/Locale  
      c2a1bc
      c2a1bc
      3.52 trunk/Scripts/Bash/Functions/Manual  
      c2a1bc
      c2a1bc
      3.53 trunk/Scripts/Bash/Functions/Path  
      c2a1bc
      c2a1bc
      3.54 trunk/Scripts/Bash/Functions/Render  
      c2a1bc
      c2a1bc
      3.55 trunk/Scripts/Bash/Functions/Render/Config  
      c2a1bc
      c2a1bc
      3.56 trunk/Scripts/Bash/Functions/Shell  
      c2a1bc
      c2a1bc
      3.57 trunk/Scripts/Bash/Functions/Svg  
      7fa1fb
      c2a1bc
      3.58 trunk/Scripts/Bash/Functions/Verify  
      c2a1bc
      c2a1bc
      c2a1bc
      c2a1bc
      c2a1bc
      c2a1bc

      3.49.4 See also

      c2a1bc
      c2a1bc
      c2a1bc
      3.48 trunk/Scripts/Bash  
      2dc146
      c2a1bc
      3.59 trunk/Scripts/Bash/Locale  
      2dc146
      2dc146
      4c79b5
      4c79b5
      4c79b5
      c2a1bc
      [ < ]
      c2a1bc
      [ > ]
      4c79b5
         
      4c79b5
      [ << ]
      2dc146
      [ Up ]
      c2a1bc
      [ >> ]
      4c79b5
      4c79b5

      4c79b5
       <font size="-1">
      acd47b
        This document was generated on February, 26 2011 using texi2html 1.76.
      4c79b5
       </font>
      4c79b5
       
      4c79b5
      4c79b5

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