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
-->
bf28e1
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>
7e35dc
<title>CentOS Artwork Repository: 3.49 trunk/Scripts/Bash/Functions</title>
4c79b5
7e35dc
<meta name="description" content="CentOS Artwork Repository: 3.49 trunk/Scripts/Bash/Functions">
7e35dc
<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
af3979
[ < ]
af3979
[ > ]
4c79b5
   
4c79b5
[ << ]
4c79b5
[ Up ]
af3979
[ >> ]
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
[Top]
4c79b5
[Contents]
af3979
[Index]
4c79b5
[ ? ]
4c79b5
7e35dc
af3979
7e35dc

3.49 trunk/Scripts/Bash/Functions

2dc146
2dc146
af3979
2dc146

3.49.1 Goals

2dc146
7e35dc

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

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

2dc146
af3979
2dc146

3.49.2 Description

2dc146
7e35dc

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

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

7e35dc

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

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

7e35dc

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

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

7e35dc

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

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

7e35dc
Info

Tip

Join CentOS developers mailing list

7e35dc
centos-art@centos.org to share your ideas.
7e35dc

7e35dc
7e35dc

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

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

7e35dc

OK, let's begin with our functionality example.

7e35dc

7e35dc

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

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

7e35dc

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

7e35dc

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

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

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

7e35dc

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

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

7e35dc

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

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

7e35dc

In our greet function example, top commentary for

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

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

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

7e35dc
function definition would look like the following:
7e35dc

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

The first definition inside greet function, are global

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

7e35dc

Later, we call greet_getActions function to define the

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

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

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

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

7e35dc

The greet function definition makes available two valid

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

7e35dc

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

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

7e35dc

The greet_doHello and greet_doBye function definitions

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

7e35dc
function greet_doHello {
7e35dc
7e35dc
    cli_printMessage "`gettext "Hello"` $ACTIONVAL"
7e35dc
7e35dc
}
7e35dc
7e35dc

The greet_doHello function definition is stored in

7e35dc
<tt>`greet_doHello.sh'</tt> function script. 
7e35dc

7e35dc
function greet_doBye {
7e35dc
7e35dc
    cli_printMessage "`gettext "Goodbye"` $ACTIONVAL"
7e35dc
7e35dc
}
7e35dc
7e35dc

The greet_doBye function definition is stored in the

7e35dc
<tt>`greet_doBye.sh'</tt> function script. 
7e35dc

7e35dc

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

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

7e35dc

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

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

7e35dc

Let's see how greet specific functionality files are organzied

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

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

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

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

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

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

7e35dc
change it to have a little fun.
7e35dc

7e35dc

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

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

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

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

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

7e35dc

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

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

7e35dc
centos-art locale --edit
7e35dc
7e35dc
Warning

Warning

To translate output messages in different languages,

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

7e35dc
7e35dc

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

7e35dc

7e35dc

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

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

7e35dc

The greet function described in this section may serve you as

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

7e35dc

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

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

2dc146
af3979
2dc146

3.49.3 Usage

008ee0
c2a1bc
af3979
7e35dc

3.49.3.1 Global variables

7e35dc
7e35dc

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

7e35dc
available for you to use inside specific functions:
7e35dc

7e35dc
7e35dc
<u>Variable:</u> TEXTDOMAIN
7e35dc
7e35dc
7e35dc

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

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

7e35dc
7e35dc
7e35dc
<u>Variable:</u> TEXTDOMAINDIR
7e35dc
7e35dc
7e35dc

Default directory used to retrieve translated messages. This value is

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

c2a1bc
7e35dc
7e35dc
<u>Variable:</u> FUNCNAM
7e35dc
7e35dc
7e35dc

Define function name.

7e35dc

7e35dc

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

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

7e35dc

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

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

7e35dc

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

7e35dc
immediatly ends its execution.
7e35dc

7e35dc
7e35dc
7e35dc
<u>Variable:</u> FUNCDIR
7e35dc
7e35dc
7e35dc
7e35dc
7e35dc
7e35dc
<u>Variable:</u> FUNCDIRNAME
7e35dc
7e35dc
7e35dc
7e35dc
7e35dc
7e35dc
<u>Variable:</u> FUNCSCRIPT
7e35dc
7e35dc
7e35dc
7e35dc
7e35dc
7e35dc
<u>Variable:</u> FUNCCONFIG
7e35dc
7e35dc
7e35dc
7e35dc
7e35dc
7e35dc
<u>Variable:</u> ACTIONNAM
7e35dc
7e35dc
7e35dc

Define action name.

7e35dc

7e35dc

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

7e35dc
specific function.
7e35dc

7e35dc

Action name names aare passed as second argument in

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

7e35dc

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

7e35dc
immediatly ends its execution.
7e35dc

7e35dc
7e35dc
7e35dc
<u>Variable:</u> ACTIONVAL
7e35dc
7e35dc
7e35dc

Define action value.

7e35dc

7e35dc

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

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

7e35dc
7e35dc
7e35dc
<u>Variable:</u> REGEX
7e35dc
7e35dc
7e35dc

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

7e35dc
to process.
7e35dc

7e35dc

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

7e35dc
files.
7e35dc

7e35dc

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

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

7e35dc
7e35dc
7e35dc
<u>Variable:</u> ARGUMENTS
7e35dc
7e35dc
7e35dc

Define optional arguments.

7e35dc

7e35dc

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

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

7e35dc

Optional arguments are parsed using getopt command through

7e35dc
the following base construction: 
7e35dc

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

Optional arguments provide support to command options inside

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

7e35dc

The ARGUMENTS variable is used to store arguments passed from

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

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

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

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

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

When getopt parses ARGUMENTS, we may use short options

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

7e35dc

In order for getopt to parse ARGUMENTS correctly, it

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

7e35dc

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

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

7e35dc

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

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

7e35dc
7e35dc
7e35dc
<u>Variable:</u> EDITOR
7e35dc
7e35dc
7e35dc

Default text editor.

7e35dc

7e35dc

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

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

7e35dc

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

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

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

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

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

    7e35dc
    7e35dc
    af3979
    7e35dc

    3.49.3.2 Global functions

    7e35dc
    7e35dc

    Function scripts stored directly under

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

    7e35dc
    7e35dc
    <u>Function:</u> cli_checkActionArguments
    7e35dc
    7e35dc
    7e35dc

    Validate action value (ACTIONVAL) variable.

    7e35dc

    7e35dc

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

    7e35dc

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

      If another value different from that specified above is passed to

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_checkFiles FILE [TYPE]
      7e35dc
      7e35dc
      7e35dc

      Verify file existence.

      7e35dc

      7e35dc

      cli_checkFiles receives a FILE absolute path and performs

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

      7e35dc
      7e35dc
      <samp>`d'</samp>
      7e35dc
      <samp>`directory'</samp>
      7e35dc

      Ends script execution if FILE is not a directory.

      7e35dc

      7e35dc

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

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

      7e35dc
      7e35dc
      <samp>`f'</samp>
      7e35dc
      <samp>`regular-file'</samp>
      7e35dc

      Ends script execution if FILE is not a regular file.

      7e35dc

      7e35dc
      <samp>`h'</samp>
      7e35dc
      <samp>`symbolic-link'</samp>
      7e35dc

      Ends script execution if FILE is not a symbolic link.

      7e35dc

      7e35dc
      <samp>`x'</samp>
      7e35dc
      <samp>`execution'</samp>
      7e35dc

      Ends script execution if FILE is not executable.

      7e35dc

      7e35dc
      <samp>`fh'</samp>
      7e35dc

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

      7e35dc
      symbolic link.
      7e35dc

      7e35dc
      <samp>`fd'</samp>
      7e35dc

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

      7e35dc
      directory.
      7e35dc

      7e35dc
      <samp>`isInWorkingCopy'</samp>
      7e35dc

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

      7e35dc

      7e35dc
      7e35dc
      7e35dc

      As default behaviour, if FILE passes all verifications,

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_commitRepoChanges [LOCATION]
      7e35dc
      7e35dc
      7e35dc

      Syncronize changes between repository and working copy.

      7e35dc

      7e35dc

      The cli_commitRepoChanges function brings changes from the

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

      7e35dc

      Previous to commit the working copy changes up to the central

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

      7e35dc

      If LOCATION argument is not specified, the value of

      7e35dc
      ACTIONVAL variable is used as reference instead.
      7e35dc

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

      Figure 3.3: The cli_commitRepoChanges function output.

      7e35dc
      7e35dc

      7e35dc

      Call the cli_commitRepoChanges function before or/and after

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_doParseArguments
      7e35dc
      7e35dc
      7e35dc

      Redefine arguments (ARGUMENTS) global variable using

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_doParseArgumentsReDef $@
      7e35dc
      7e35dc
      7e35dc

      Initialize/reset arguments (ARGUMENTS) global variable using

      7e35dc
      positional parameters variable ($@) as reference.
      7e35dc

      7e35dc

      When we work inside function definitions, positional parameters are

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_getArguments
      7e35dc
      7e35dc
      7e35dc

      Initialize function name (FUNCNAM), action name

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

      7e35dc

      The cli_getArguments function is called from cli.sh

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

      7e35dc

      Once command-line positional parameters are accesible to

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

      7e35dc

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

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

      7e35dc

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

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

      7e35dc

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

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_getFunctions
      7e35dc
      7e35dc
      7e35dc

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

      7e35dc

      7e35dc

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

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

      7e35dc

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

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

      7e35dc

      Inside each functionality directory, the functionalty itself is

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

      7e35dc

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

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

      7e35dc
      function prefix_doSomething {
      7e35dc
      7e35dc
          # Do something here...
      7e35dc
      7e35dc
      }
      7e35dc
      7e35dc

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

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

      7e35dc

      If the functionality specified in the command-line first argument

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

      7e35dc

      In order to keep visual consistency among function scripts, please

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

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

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

      7e35dc

      7e35dc

      The cli_getCountryCodes function outputs a list with country

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_getCountryName [FILTER]
      7e35dc
      7e35dc
      7e35dc

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

      7e35dc

      7e35dc

      The cli_getCountryName function reads one language locale code

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

      7e35dc
       
      7e35dc
      7e35dc
      <u>Function:</u> cli_getCurrentLocale
      7e35dc
      7e35dc
      7e35dc

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

      7e35dc

      7e35dc

      The cli_getCurrentLocale function uses LANG environment

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

      7e35dc

      The current locale information, returned by

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

      7e35dc

      Locale precedence selection is quite important in order to define the

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

      7e35dc

      Use cli_getCurrentLocale function to know what current locale

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_getFilesList [LOCATION]
      7e35dc
      7e35dc
      7e35dc

      Output list of files to process.

      7e35dc

      7e35dc

      The cli_getFilesList function uses LOCATION variable as

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

      7e35dc

      If LOCATION is not specified when cli_getFilesList

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

      7e35dc

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

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

      7e35dc

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

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

      7e35dc

      As result, the cli_getFilesList re-defines the value of

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

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

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

      7e35dc

      7e35dc

      cli_getLangCodes function outputs a list of language codes as

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_getLangName [FILTER]
      7e35dc
      7e35dc
      7e35dc

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

      7e35dc

      7e35dc

      cli_getLangName function reads one language locale code in the

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_getLocales
      7e35dc
      7e35dc
      7e35dc

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

      7e35dc

      7e35dc

      Occasionally, you use cli_getLocales function to add locale

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_getRepoName NAME TYPE
      7e35dc
      7e35dc
      7e35dc

      Sanitate file names.

      7e35dc

      7e35dc

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

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

      7e35dc
      Important

      Important

      cli_getRepoName function doesn't verify file

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

      7e35dc
      7e35dc

      The NAME variable contains the file name or directory name you

      7e35dc
      want to sanitate.
      7e35dc

      7e35dc

      The TYPE variable specifies what type of sanitation you want to

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

      7e35dc
      7e35dc
      <samp>`d'</samp>
      7e35dc
      <samp>`directory'</samp>
      7e35dc

      Sanitate directory NAMEs.

      7e35dc

      7e35dc
      <samp>`f'</samp>
      7e35dc
      <samp>`regular-file'</samp>
      7e35dc

      Sanitate regular file NAMEs.

      7e35dc

      7e35dc
      7e35dc
      7e35dc

      Use cli_getRepoName function to sanitate file names and

      7e35dc
      directory names before their utilization. 
      7e35dc

      7e35dc

      Use cli_getRepoName when you need to change file name

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

      7e35dc

      When we change file name convenctions inside cli_getRepoName

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_getRepoStatus [LOCATION]
      7e35dc
      7e35dc
      7e35dc

      Request repository status.

      7e35dc

      7e35dc

      This function requests the status of a LOCATION inside the

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

      7e35dc

      Use this function to perform verifications based a repository

      7e35dc
      LOCATION status.
      7e35dc

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_getTemporalFile NAME
      7e35dc
      7e35dc
      7e35dc

      Output absolute path to temporal file NAME.

      7e35dc

      7e35dc

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

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

      7e35dc
      cli_getTemporalFile $FILE
      7e35dc
      7e35dc

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

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

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

      When you use the cli_getTemporalFile function to create

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

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

      Use the cli_getTemporalFile function whenever you need to

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_getThemeName
      7e35dc
      7e35dc
      7e35dc

      Output theme name.

      7e35dc

      7e35dc

      In order for cli_getThemeName function to extract theme name

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

      7e35dc
      7e35dc
      7e35dc
      <u>Function:</u> cli_printMessage MESSAGE [FORMAT]
      7e35dc
      7e35dc
      7e35dc

      Define standard output message definition supported by

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

      7e35dc

      When FORMAT is not specified, cli_printMessage outputs

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

      7e35dc
      7e35dc
      <samp>`AsHeadingLine'</samp>
      7e35dc

      To print heading messages.

      7e35dc

      ----------------------------------------------------------------------
      7e35dc
      $MESSAGE
      7e35dc
      ----------------------------------------------------------------------
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsWarningLine'</samp>
      7e35dc

      To print warning messages.

      7e35dc

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

      To print note messages.

      7e35dc

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

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

      7e35dc

      Updating        $MESSAGE
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsRemovingLine'</samp>
      7e35dc

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

      7e35dc

      Removing        $MESSAGE
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsCheckingLine'</samp>
      7e35dc

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

      7e35dc

      Checking        $MESSAGE
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsCreatingLine'</samp>
      7e35dc

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

      7e35dc

      Creating        $MESSAGE
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsSavedAsLine'</samp>
      7e35dc

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

      7e35dc

      Saved as        $MESSAGE
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsLinkToLine'</samp>
      7e35dc

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

      7e35dc

      Linked to       $MESSAGE
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsMovedToLine'</samp>
      7e35dc

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

      7e35dc

      Moved to        $MESSAGE
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsTranslationLine'</samp>
      7e35dc

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

      7e35dc

      Translation     $MESSAGE
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsConfigurationLine'</samp>
      7e35dc

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

      7e35dc

      Configuration   $MESSAGE
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsResponseLine'</samp>
      7e35dc

      To print response messages on one-column format.

      7e35dc

      --> $MESSAGE
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsRequestLine'</samp>
      7e35dc

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

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

      $MESSAGE:
      7e35dc
      7e35dc
      7e35dc
      <samp>`AsYesOrNoRequestLine'</samp>
      7e35dc

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

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

      7e35dc
      $MESSAGE [y/N]:
      7e35dc
      7e35dc

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

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

      7e35dc
      $MESSAGE [s/N]:
      7e35dc
      7e35dc

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

      7e35dc
      <samp>`sí'</samp> word.
      7e35dc

      7e35dc

      Definition of which confirmation word to use is set on translation

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

      7e35dc
      7e35dc
      <samp>`AsToKnowMoreLine'</samp>
      7e35dc

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

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

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

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

      7e35dc
      script termination. 
      7e35dc

      7e35dc
      7e35dc
      <samp>`AsRegularLine'</samp>
      7e35dc

      To standardize regular messages on one-column format.

      7e35dc

      7e35dc

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

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

      7e35dc
      7e35dc
      7e35dc

      Use cli_printMessage function whenever you need to output

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

      7e35dc
      Info

      Tip

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

      7e35dc

      trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
      7e35dc
      7e35dc
      7e35dc
      7e35dc
      af3979
      7e35dc

      3.49.3.3 Specific functions

      7e35dc
      7e35dc

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

      7e35dc
      available for you to use:
      7e35dc

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

      3.49.4 See also

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

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

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