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

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

3.49 trunk/Scripts/Bash/Cli/Functions

ee1f37
ee1f37
010b2d
ee1f37

3.49.1 Goals

ee1f37
65cd8a

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

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

ee1f37
010b2d
ee1f37

3.49.2 Description

ee1f37
65cd8a

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

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

65cd8a

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

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

65cd8a

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

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

65cd8a

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

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

65cd8a
Info

Tip

Join CentOS developers mailing list

65cd8a
centos-art@centos.org to share your ideas.
65cd8a

65cd8a
65cd8a

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

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

65cd8a

OK, let's begin with our functionality example.

65cd8a

65cd8a

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

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

65cd8a

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

65cd8a

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

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

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

65cd8a

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

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

65cd8a

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

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

65cd8a

In our greet function example, top commentary for

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

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

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

65cd8a
function definition would look like the following:
65cd8a

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

The first definition inside greet function, are global

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

65cd8a

Later, we call greet_getActions function to define the

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

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

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

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

65cd8a

The greet function definition makes available two valid

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

65cd8a

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

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

65cd8a

The greet_doHello and greet_doBye function definitions

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

65cd8a
function greet_doHello {
65cd8a
65cd8a
    cli_printMessage "`gettext "Hello"` $ACTIONVAL"
65cd8a
65cd8a
}
65cd8a
65cd8a

The greet_doHello function definition is stored in

65cd8a
<tt>`greet_doHello.sh'</tt> function script. 
65cd8a

65cd8a
function greet_doBye {
65cd8a
65cd8a
    cli_printMessage "`gettext "Goodbye"` $ACTIONVAL"
65cd8a
65cd8a
}
65cd8a
65cd8a

The greet_doBye function definition is stored in the

65cd8a
<tt>`greet_doBye.sh'</tt> function script. 
65cd8a

65cd8a

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

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

65cd8a

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

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

65cd8a

Let's see how greet specific functionality files are organzied

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

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

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

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

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

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

65cd8a
change it to have a little fun.
65cd8a

65cd8a

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

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

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

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

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

65cd8a

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

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

65cd8a
centos-art locale --edit
65cd8a
65cd8a
Warning

Warning

To translate output messages in different languages,

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

65cd8a
65cd8a

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

65cd8a

65cd8a

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

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

65cd8a

The greet function described in this section may serve you as

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

65cd8a

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

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

ee1f37
010b2d
ee1f37

3.49.3 Usage

ee1f37
65cd8a
65cd8a
65cd8a

3.49.3.1 Global variables

65cd8a
65cd8a

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

65cd8a
available for you to use inside specific functions:
65cd8a

65cd8a
65cd8a
<u>Variable:</u> TEXTDOMAIN
65cd8a
65cd8a
65cd8a

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

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

65cd8a
65cd8a
65cd8a
<u>Variable:</u> TEXTDOMAINDIR
65cd8a
65cd8a
65cd8a

Default directory used to retrieve translated messages. This value is

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

65cd8a
65cd8a
65cd8a
<u>Variable:</u> FUNCNAM
65cd8a
65cd8a
65cd8a

Define function name.

65cd8a

65cd8a

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

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

65cd8a

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

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

65cd8a

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

65cd8a
immediatly ends its execution.
65cd8a

65cd8a
65cd8a
65cd8a
<u>Variable:</u> FUNCDIR
65cd8a
65cd8a
65cd8a
65cd8a
65cd8a
65cd8a
<u>Variable:</u> FUNCDIRNAME
65cd8a
65cd8a
65cd8a
65cd8a
65cd8a
65cd8a
<u>Variable:</u> FUNCSCRIPT
65cd8a
65cd8a
65cd8a
65cd8a
65cd8a
65cd8a
<u>Variable:</u> FUNCCONFIG
65cd8a
65cd8a
65cd8a
65cd8a
65cd8a
65cd8a
<u>Variable:</u> ACTIONNAM
65cd8a
65cd8a
65cd8a

Define action name.

65cd8a

65cd8a

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

65cd8a
specific function.
65cd8a

65cd8a

Action name names aare passed as second argument in

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

65cd8a

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

65cd8a
immediatly ends its execution.
65cd8a

65cd8a
65cd8a
65cd8a
<u>Variable:</u> ACTIONVAL
65cd8a
65cd8a
65cd8a

Define action value.

65cd8a

65cd8a

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

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

65cd8a
65cd8a
65cd8a
<u>Variable:</u> REGEX
65cd8a
65cd8a
65cd8a

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

65cd8a
to process.
65cd8a

65cd8a

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

65cd8a
files.
65cd8a

65cd8a

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

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

65cd8a
65cd8a
65cd8a
<u>Variable:</u> ARGUMENTS
65cd8a
65cd8a
65cd8a

Define optional arguments.

65cd8a

65cd8a

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

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

65cd8a

Optional arguments are parsed using getopt command through

65cd8a
the following base construction: 
65cd8a

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

Optional arguments provide support to command options inside

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

65cd8a

The ARGUMENTS variable is used to store arguments passed from

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

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

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

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

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

When getopt parses ARGUMENTS, we may use short options

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

65cd8a

In order for getopt to parse ARGUMENTS correctly, it

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

65cd8a

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

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

65cd8a

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

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

65cd8a
65cd8a
65cd8a
<u>Variable:</u> EDITOR
65cd8a
65cd8a
65cd8a

Default text editor.

65cd8a

65cd8a

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

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

65cd8a

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

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

ee1f37
    65cd8a
  • <tt>`/usr/bin/vim'</tt>
  • 65cd8a
  • <tt>`/usr/bin/emacs'</tt>
  • 65cd8a
  • <tt>`/usr/bin/nano'</tt>
  • ee1f37
    ee1f37
    65cd8a

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

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

    ee1f37
    65cd8a
    65cd8a
    65cd8a

    3.49.3.2 Global functions

    65cd8a
    65cd8a

    Function scripts stored directly under

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

    65cd8a
    65cd8a
    <u>Function:</u> cli_checkActionArguments
    65cd8a
    65cd8a
    65cd8a

    Validate action value (ACTIONVAL) variable.

    65cd8a

    65cd8a

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

    65cd8a

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

      If another value different from that specified above is passed to

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_checkFiles FILE [TYPE]
      65cd8a
      65cd8a
      65cd8a

      Verify file existence.

      65cd8a

      65cd8a

      cli_checkFiles receives a FILE absolute path and performs

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

      65cd8a
      65cd8a
      <samp>`d'</samp>
      65cd8a
      <samp>`directory'</samp>
      65cd8a

      Ends script execution if FILE is not a directory.

      65cd8a

      65cd8a

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

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

      65cd8a
      65cd8a
      <samp>`f'</samp>
      65cd8a
      <samp>`regular-file'</samp>
      65cd8a

      Ends script execution if FILE is not a regular file.

      65cd8a

      65cd8a
      <samp>`h'</samp>
      65cd8a
      <samp>`symbolic-link'</samp>
      65cd8a

      Ends script execution if FILE is not a symbolic link.

      65cd8a

      65cd8a
      <samp>`x'</samp>
      65cd8a
      <samp>`execution'</samp>
      65cd8a

      Ends script execution if FILE is not executable.

      65cd8a

      65cd8a
      <samp>`fh'</samp>
      65cd8a

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

      65cd8a
      symbolic link.
      65cd8a

      65cd8a
      <samp>`fd'</samp>
      65cd8a

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

      65cd8a
      directory.
      65cd8a

      65cd8a
      <samp>`isInWorkingCopy'</samp>
      65cd8a

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

      65cd8a

      65cd8a
      65cd8a
      65cd8a

      As default behaviour, if FILE passes all verifications,

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_commitRepoChanges [LOCATION]
      65cd8a
      65cd8a
      65cd8a

      Syncronize changes between repository and working copy.

      65cd8a

      65cd8a

      The cli_commitRepoChanges function brings changes from the

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

      65cd8a

      Previous to commit the working copy changes up to the central

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

      65cd8a

      If LOCATION argument is not specified, the value of

      65cd8a
      ACTIONVAL variable is used as reference instead.
      65cd8a

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

      Figure 3.3: The cli_commitRepoChanges function output.

      65cd8a
      65cd8a

      65cd8a

      Call the cli_commitRepoChanges function before or/and after

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_doParseArguments
      65cd8a
      65cd8a
      65cd8a

      Redefine arguments (ARGUMENTS) global variable using

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_doParseArgumentsReDef $@
      65cd8a
      65cd8a
      65cd8a

      Initialize/reset arguments (ARGUMENTS) global variable using

      65cd8a
      positional parameters variable ($@) as reference.
      65cd8a

      65cd8a

      When we work inside function definitions, positional parameters are

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_getArguments
      65cd8a
      65cd8a
      65cd8a

      Initialize function name (FUNCNAM), action name

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

      65cd8a

      The cli_getArguments function is called from cli.sh

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

      65cd8a

      Once command-line positional parameters are accesible to

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

      65cd8a

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

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

      65cd8a

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

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

      65cd8a

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

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_getFunctions
      65cd8a
      65cd8a
      65cd8a

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

      65cd8a

      65cd8a

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

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

      65cd8a

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

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

      65cd8a

      Inside each functionality directory, the functionalty itself is

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

      65cd8a

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

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

      65cd8a
      function prefix_doSomething {
      65cd8a
      65cd8a
          # Do something here...
      65cd8a
      65cd8a
      }
      65cd8a
      65cd8a

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

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

      65cd8a

      If the functionality specified in the command-line first argument

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

      65cd8a

      In order to keep visual consistency among function scripts, please

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

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

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

      65cd8a

      65cd8a

      The cli_getCountryCodes function outputs a list with country

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_getCountryName [FILTER]
      65cd8a
      65cd8a
      65cd8a

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

      65cd8a

      65cd8a

      The cli_getCountryName function reads one language locale code

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

      65cd8a
       
      65cd8a
      65cd8a
      <u>Function:</u> cli_getCurrentLocale
      65cd8a
      65cd8a
      65cd8a

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

      65cd8a

      65cd8a

      The cli_getCurrentLocale function uses LANG environment

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

      65cd8a

      The current locale information, returned by

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

      65cd8a

      Locale precedence selection is quite important in order to define the

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

      65cd8a

      Use cli_getCurrentLocale function to know what current locale

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_getFilesList [LOCATION]
      65cd8a
      65cd8a
      65cd8a

      Output list of files to process.

      65cd8a

      65cd8a

      The cli_getFilesList function uses LOCATION variable as

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

      65cd8a

      If LOCATION is not specified when cli_getFilesList

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

      65cd8a

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

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

      65cd8a

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

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

      65cd8a

      As result, the cli_getFilesList re-defines the value of

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

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

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

      65cd8a

      65cd8a

      cli_getLangCodes function outputs a list of language codes as

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_getLangName [FILTER]
      65cd8a
      65cd8a
      65cd8a

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

      65cd8a

      65cd8a

      cli_getLangName function reads one language locale code in the

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_getLocales
      65cd8a
      65cd8a
      65cd8a

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

      65cd8a

      65cd8a

      Occasionally, you use cli_getLocales function to add locale

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_getRepoName NAME TYPE
      65cd8a
      65cd8a
      65cd8a

      Sanitate file names.

      65cd8a

      65cd8a

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

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

      65cd8a
      Important

      Important

      cli_getRepoName function doesn't verify file

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

      65cd8a
      65cd8a

      The NAME variable contains the file name or directory name you

      65cd8a
      want to sanitate.
      65cd8a

      65cd8a

      The TYPE variable specifies what type of sanitation you want to

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

      65cd8a
      65cd8a
      <samp>`d'</samp>
      65cd8a
      <samp>`directory'</samp>
      65cd8a

      Sanitate directory NAMEs.

      65cd8a

      65cd8a
      <samp>`f'</samp>
      65cd8a
      <samp>`regular-file'</samp>
      65cd8a

      Sanitate regular file NAMEs.

      65cd8a

      65cd8a
      65cd8a
      65cd8a

      Use cli_getRepoName function to sanitate file names and

      65cd8a
      directory names before their utilization. 
      65cd8a

      65cd8a

      Use cli_getRepoName when you need to change file name

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

      65cd8a

      When we change file name convenctions inside cli_getRepoName

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_getRepoStatus [LOCATION]
      65cd8a
      65cd8a
      65cd8a

      Request repository status.

      65cd8a

      65cd8a

      This function requests the status of a LOCATION inside the

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

      65cd8a

      Use this function to perform verifications based a repository

      65cd8a
      LOCATION status.
      65cd8a

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_getTemporalFile NAME
      65cd8a
      65cd8a
      65cd8a

      Output absolute path to temporal file NAME.

      65cd8a

      65cd8a

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

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

      65cd8a
      cli_getTemporalFile $FILE
      65cd8a
      65cd8a

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

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

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

      When you use the cli_getTemporalFile function to create

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

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

      Use the cli_getTemporalFile function whenever you need to

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_getThemeName
      65cd8a
      65cd8a
      65cd8a

      Output theme name.

      65cd8a

      65cd8a

      In order for cli_getThemeName function to extract theme name

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

      65cd8a
      65cd8a
      65cd8a
      <u>Function:</u> cli_printMessage MESSAGE [FORMAT]
      65cd8a
      65cd8a
      65cd8a

      Define standard output message definition supported by

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

      65cd8a

      When FORMAT is not specified, cli_printMessage outputs

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

      65cd8a
      65cd8a
      <samp>`AsHeadingLine'</samp>
      65cd8a

      To print heading messages.

      65cd8a

      ----------------------------------------------------------------------
      65cd8a
      $MESSAGE
      65cd8a
      ----------------------------------------------------------------------
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsWarningLine'</samp>
      65cd8a

      To print warning messages.

      65cd8a

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

      To print note messages.

      65cd8a

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

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

      65cd8a

      Updating        $MESSAGE
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsRemovingLine'</samp>
      65cd8a

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

      65cd8a

      Removing        $MESSAGE
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsCheckingLine'</samp>
      65cd8a

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

      65cd8a

      Checking        $MESSAGE
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsCreatingLine'</samp>
      65cd8a

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

      65cd8a

      Creating        $MESSAGE
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsSavedAsLine'</samp>
      65cd8a

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

      65cd8a

      Saved as        $MESSAGE
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsLinkToLine'</samp>
      65cd8a

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

      65cd8a

      Linked to       $MESSAGE
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsMovedToLine'</samp>
      65cd8a

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

      65cd8a

      Moved to        $MESSAGE
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsTranslationLine'</samp>
      65cd8a

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

      65cd8a

      Translation     $MESSAGE
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsConfigurationLine'</samp>
      65cd8a

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

      65cd8a

      Configuration   $MESSAGE
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsResponseLine'</samp>
      65cd8a

      To print response messages on one-column format.

      65cd8a

      --> $MESSAGE
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsRequestLine'</samp>
      65cd8a

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

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

      $MESSAGE:
      65cd8a
      65cd8a
      65cd8a
      <samp>`AsYesOrNoRequestLine'</samp>
      65cd8a

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

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

      65cd8a
      $MESSAGE [y/N]:
      65cd8a
      65cd8a

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

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

      65cd8a
      $MESSAGE [s/N]:
      65cd8a
      65cd8a

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

      65cd8a
      <samp>`sí'</samp> word.
      65cd8a

      65cd8a

      Definition of which confirmation word to use is set on translation

      65cd8a
      messages for your specific locale information. -- Removed(xref:trunk Scripts
      65cd8a
      Bash Functions Locale) --, for more information about locale-specific
      65cd8a
      translation messages.
      65cd8a

      65cd8a
      65cd8a
      <samp>`AsToKnowMoreLine'</samp>
      65cd8a

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

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

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

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

      65cd8a
      script termination. 
      65cd8a

      65cd8a
      65cd8a
      <samp>`AsRegularLine'</samp>
      65cd8a

      To standardize regular messages on one-column format.

      65cd8a

      65cd8a

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

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

      65cd8a
      65cd8a
      65cd8a

      Use cli_printMessage function whenever you need to output

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

      65cd8a
      Info

      Tip

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

      65cd8a

      trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
      65cd8a
      65cd8a
      65cd8a
      65cd8a
      65cd8a
      65cd8a

      3.49.3.3 Specific functions

      65cd8a
      65cd8a

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

      65cd8a
      available for you to use:
      65cd8a

      65cd8a
      65cd8a
      65cd8a
      ee1f37

      3.49.4 See also

      ee1f37
      65cd8a
      56a476
      3.47 trunk/Scripts/Bash  
      65cd8a
      65cd8a
      ee1f37
      ee1f37
      ee1f37
      65cd8a
      [ < ]
      56a476
      [ > ]
      ee1f37
         
      56a476
      [ << ]
      010b2d
      [ Up ]
      56a476
      [ >> ]
      ee1f37
      ee1f37

      ee1f37
       <font size="-1">
      406f69
        This document was generated on March, 1 2011 using texi2html 1.76.
      ee1f37
       </font>
      ee1f37
       
      ee1f37
      ee1f37

      ee1f37
      </body>
      ee1f37
      </html>