Blame Manual/repository-html/repository_53.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>
5cb5a7
<title>CentOS Artwork Repository: 2.51 Filesystem/trunk/Scripts/Bash/Cli/Functions</title>
ee1f37
5cb5a7
<meta name="description" content="CentOS Artwork Repository: 2.51 Filesystem/trunk/Scripts/Bash/Cli/Functions">
5cb5a7
<meta name="keywords" content="CentOS Artwork Repository: 2.51 Filesystem/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
982d5c
[ < ]
982d5c
[ > ]
ee1f37
   
982d5c
[ << ]
982d5c
[ Up ]
5cb5a7
[ >> ]
ee1f37
   
ee1f37
   
ee1f37
   
ee1f37
   
56a476
[Top]
56a476
[Contents]
5cb5a7
[Index]
56a476
[ ? ]
ee1f37
982d5c
982d5c
5cb5a7

2.51 Filesystem/trunk/Scripts/Bash/Cli/Functions

982d5c
982d5c
982d5c
982d5c

2.51.1 Goals

982d5c
982d5c

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

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

982d5c
982d5c
982d5c

2.51.2 Description

982d5c
982d5c

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

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

982d5c

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

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

982d5c

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

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

982d5c

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

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

982d5c
Info

Tip

Join CentOS developers mailing list

982d5c
centos-art@centos.org to share your ideas.
982d5c

982d5c
982d5c

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

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

982d5c

OK, let's begin with our functionality example.

982d5c

982d5c

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

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

982d5c

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

982d5c

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

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

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

982d5c

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

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

982d5c

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

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

982d5c

In our greet function example, top commentary for

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

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

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

982d5c
function definition would look like the following:
982d5c

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

The first definition inside greet function, are global

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

982d5c

Later, we call greet_getActions function to define the

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

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

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

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

982d5c

The greet function definition makes available two valid

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

982d5c

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

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

982d5c

The greet_doHello and greet_doBye function definitions

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

982d5c
function greet_doHello {
982d5c
982d5c
    cli_printMessage "`gettext "Hello"` $ACTIONVAL"
982d5c
982d5c
}
982d5c
982d5c

The greet_doHello function definition is stored in

982d5c
<tt>`greet_doHello.sh'</tt> function script. 
982d5c

982d5c
function greet_doBye {
982d5c
982d5c
    cli_printMessage "`gettext "Goodbye"` $ACTIONVAL"
982d5c
982d5c
}
982d5c
982d5c

The greet_doBye function definition is stored in the

982d5c
<tt>`greet_doBye.sh'</tt> function script. 
982d5c

982d5c

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

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

982d5c

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

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

982d5c

Let's see how greet specific functionality files are organzied

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

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

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

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

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

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

982d5c
change it to have a little fun.
982d5c

982d5c

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

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

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

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

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

982d5c

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

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

982d5c
centos-art locale --edit
982d5c
982d5c
Warning

Warning

To translate output messages in different languages,

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

982d5c
982d5c

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

982d5c

982d5c

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

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

982d5c

The greet function described in this section may serve you as

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

982d5c

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

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

982d5c
010b2d
982d5c

2.51.3 Usage

010b2d
010b2d
010b2d
982d5c

2.51.3.1 Global variables

982d5c
982d5c

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

982d5c
available for you to use inside specific functions:
982d5c

982d5c
982d5c
<u>Variable:</u> TEXTDOMAIN
982d5c
982d5c
982d5c

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

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

982d5c
982d5c
982d5c
<u>Variable:</u> TEXTDOMAINDIR
982d5c
982d5c
982d5c

Default directory used to retrieve translated messages. This value is

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

982d5c
982d5c
982d5c
<u>Variable:</u> FUNCNAM
982d5c
982d5c
982d5c

Define function name.

982d5c

982d5c

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

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

982d5c

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

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

982d5c

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

982d5c
immediatly ends its execution.
982d5c

982d5c
982d5c
982d5c
<u>Variable:</u> FUNCDIR
982d5c
982d5c
982d5c
982d5c
982d5c
982d5c
<u>Variable:</u> FUNCDIRNAME
982d5c
982d5c
982d5c
982d5c
982d5c
982d5c
<u>Variable:</u> FUNCSCRIPT
982d5c
982d5c
982d5c
982d5c
982d5c
982d5c
<u>Variable:</u> FUNCCONFIG
982d5c
982d5c
982d5c
982d5c
982d5c
982d5c
<u>Variable:</u> ACTIONNAM
982d5c
982d5c
982d5c

Define action name.

982d5c

982d5c

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

982d5c
specific function.
982d5c

982d5c

Action name names aare passed as second argument in

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

982d5c

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

982d5c
immediatly ends its execution.
982d5c

982d5c
982d5c
982d5c
<u>Variable:</u> ACTIONVAL
982d5c
982d5c
982d5c

Define action value.

982d5c

982d5c

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

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

982d5c
982d5c
982d5c
<u>Variable:</u> REGEX
982d5c
982d5c
982d5c

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

982d5c
to process.
982d5c

982d5c

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

982d5c
files.
982d5c

982d5c

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

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

010b2d
982d5c
982d5c
<u>Variable:</u> ARGUMENTS
982d5c
982d5c
982d5c

Define optional arguments.

982d5c

982d5c

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

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

982d5c

Optional arguments are parsed using getopt command through

982d5c
the following base construction: 
982d5c

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

Optional arguments provide support to command options inside

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

982d5c

The ARGUMENTS variable is used to store arguments passed from

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

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

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

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

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

When getopt parses ARGUMENTS, we may use short options

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

982d5c

In order for getopt to parse ARGUMENTS correctly, it

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

982d5c

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

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

982d5c

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

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

982d5c
982d5c
982d5c
<u>Variable:</u> EDITOR
982d5c
982d5c
982d5c

Default text editor.

982d5c

982d5c

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

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

982d5c

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

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

ee1f37
    982d5c
  • <tt>`/usr/bin/vim'</tt>
  • 982d5c
  • <tt>`/usr/bin/emacs'</tt>
  • 982d5c
  • <tt>`/usr/bin/nano'</tt>
  • ee1f37
    ee1f37
    982d5c

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

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

    982d5c
    ee1f37
    010b2d
    982d5c

    2.51.3.2 Global functions

    ee1f37
    982d5c

    Function scripts stored directly under

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

    982d5c
    982d5c
    <u>Function:</u> cli_checkActionArguments
    982d5c
    982d5c
    982d5c

    Validate action value (ACTIONVAL) variable.

    982d5c

    982d5c

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

    982d5c

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

      If another value different from that specified above is passed to

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_checkFiles FILE [TYPE]
      982d5c
      982d5c
      982d5c

      Verify file existence.

      982d5c

      982d5c

      cli_checkFiles receives a FILE absolute path and performs

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

      982d5c
      982d5c
      <samp>`d'</samp>
      982d5c
      <samp>`directory'</samp>
      982d5c

      Ends script execution if FILE is not a directory.

      982d5c

      982d5c

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

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

      982d5c
      982d5c
      <samp>`f'</samp>
      982d5c
      <samp>`regular-file'</samp>
      982d5c

      Ends script execution if FILE is not a regular file.

      982d5c

      982d5c
      <samp>`h'</samp>
      982d5c
      <samp>`symbolic-link'</samp>
      982d5c

      Ends script execution if FILE is not a symbolic link.

      982d5c

      982d5c
      <samp>`x'</samp>
      982d5c
      <samp>`execution'</samp>
      982d5c

      Ends script execution if FILE is not executable.

      982d5c

      982d5c
      <samp>`fh'</samp>
      982d5c

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

      982d5c
      symbolic link.
      982d5c

      982d5c
      <samp>`fd'</samp>
      982d5c

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

      982d5c
      directory.
      982d5c

      982d5c
      <samp>`isInWorkingCopy'</samp>
      982d5c

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

      982d5c

      982d5c
      982d5c
      982d5c

      As default behaviour, if FILE passes all verifications,

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_commitRepoChanges [LOCATION]
      982d5c
      982d5c
      982d5c

      Syncronize changes between repository and working copy.

      982d5c

      982d5c

      The cli_commitRepoChanges function brings changes from the

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

      982d5c

      Previous to commit the working copy changes up to the central

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

      982d5c

      If LOCATION argument is not specified, the value of

      982d5c
      ACTIONVAL variable is used as reference instead.
      982d5c

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

      Figure 2.3: The cli_commitRepoChanges function output.

      982d5c
      982d5c

      982d5c

      Call the cli_commitRepoChanges function before or/and after

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_doParseArguments
      982d5c
      982d5c
      982d5c

      Redefine arguments (ARGUMENTS) global variable using

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_doParseArgumentsReDef $@
      982d5c
      982d5c
      982d5c

      Initialize/reset arguments (ARGUMENTS) global variable using

      982d5c
      positional parameters variable ($@) as reference.
      982d5c

      982d5c

      When we work inside function definitions, positional parameters are

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_getArguments
      982d5c
      982d5c
      982d5c

      Initialize function name (FUNCNAM), action name

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

      982d5c

      The cli_getArguments function is called from cli.sh

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

      982d5c

      Once command-line positional parameters are accesible to

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

      982d5c

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

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

      982d5c

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

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

      982d5c

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

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_getFunctions
      982d5c
      982d5c
      982d5c

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

      982d5c

      982d5c

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

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

      982d5c

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

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

      982d5c

      Inside each functionality directory, the functionalty itself is

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

      982d5c

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

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

      982d5c
      function prefix_doSomething {
      982d5c
      982d5c
          # Do something here...
      982d5c
      982d5c
      }
      982d5c
      982d5c

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

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

      982d5c

      If the functionality specified in the command-line first argument

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

      982d5c

      In order to keep visual consistency among function scripts, please

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

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

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

      982d5c

      982d5c

      The cli_getCountryCodes function outputs a list with country

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_getCountryName [FILTER]
      982d5c
      982d5c
      982d5c

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

      982d5c

      982d5c

      The cli_getCountryName function reads one language locale code

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

      982d5c
       
      982d5c
      982d5c
      <u>Function:</u> cli_getCurrentLocale
      982d5c
      982d5c
      982d5c

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

      982d5c

      982d5c

      The cli_getCurrentLocale function uses LANG environment

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

      982d5c

      The current locale information, returned by

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

      982d5c

      Locale precedence selection is quite important in order to define the

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

      982d5c

      Use cli_getCurrentLocale function to know what current locale

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_getFilesList [LOCATION]
      982d5c
      982d5c
      982d5c

      Output list of files to process.

      982d5c

      982d5c

      The cli_getFilesList function uses LOCATION variable as

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

      982d5c

      If LOCATION is not specified when cli_getFilesList

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

      982d5c

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

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

      982d5c

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

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

      982d5c

      As result, the cli_getFilesList re-defines the value of

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

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

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

      982d5c

      982d5c

      cli_getLangCodes function outputs a list of language codes as

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_getLangName [FILTER]
      982d5c
      982d5c
      982d5c

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

      982d5c

      982d5c

      cli_getLangName function reads one language locale code in the

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_getLocales
      982d5c
      982d5c
      982d5c

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

      982d5c

      982d5c

      Occasionally, you use cli_getLocales function to add locale

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_getRepoName NAME TYPE
      982d5c
      982d5c
      982d5c

      Sanitate file names.

      982d5c

      982d5c

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

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

      982d5c
      Important

      Important

      cli_getRepoName function doesn't verify file

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

      982d5c
      982d5c

      The NAME variable contains the file name or directory name you

      982d5c
      want to sanitate.
      982d5c

      982d5c

      The TYPE variable specifies what type of sanitation you want to

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

      982d5c
      982d5c
      <samp>`d'</samp>
      982d5c
      <samp>`directory'</samp>
      982d5c

      Sanitate directory NAMEs.

      982d5c

      982d5c
      <samp>`f'</samp>
      982d5c
      <samp>`regular-file'</samp>
      982d5c

      Sanitate regular file NAMEs.

      982d5c

      982d5c
      982d5c
      982d5c

      Use cli_getRepoName function to sanitate file names and

      982d5c
      directory names before their utilization. 
      982d5c

      982d5c

      Use cli_getRepoName when you need to change file name

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

      982d5c

      When we change file name convenctions inside cli_getRepoName

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_getRepoStatus [LOCATION]
      982d5c
      982d5c
      982d5c

      Request repository status.

      982d5c

      982d5c

      This function requests the status of a LOCATION inside the

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

      982d5c

      Use this function to perform verifications based a repository

      982d5c
      LOCATION status.
      982d5c

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_getTemporalFile NAME
      982d5c
      982d5c
      982d5c

      Output absolute path to temporal file NAME.

      982d5c

      982d5c

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

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

      982d5c
      cli_getTemporalFile $FILE
      982d5c
      982d5c

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

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

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

      When you use the cli_getTemporalFile function to create

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

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

      Use the cli_getTemporalFile function whenever you need to

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_getThemeName
      982d5c
      982d5c
      982d5c

      Output theme name.

      982d5c

      982d5c

      In order for cli_getThemeName function to extract theme name

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

      982d5c
      982d5c
      982d5c
      <u>Function:</u> cli_printMessage MESSAGE [FORMAT]
      982d5c
      982d5c
      982d5c

      Define standard output message definition supported by

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

      982d5c

      When FORMAT is not specified, cli_printMessage outputs

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

      982d5c
      982d5c
      <samp>`AsHeadingLine'</samp>
      982d5c

      To print heading messages.

      982d5c

      ----------------------------------------------------------------------
      982d5c
      $MESSAGE
      982d5c
      ----------------------------------------------------------------------
      982d5c
      982d5c
      982d5c
      <samp>`AsWarningLine'</samp>
      982d5c

      To print warning messages.

      982d5c

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

      To print note messages.

      982d5c

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

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

      982d5c

      Updating        $MESSAGE
      982d5c
      982d5c
      982d5c
      <samp>`AsRemovingLine'</samp>
      982d5c

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

      982d5c

      Removing        $MESSAGE
      982d5c
      982d5c
      982d5c
      <samp>`AsCheckingLine'</samp>
      982d5c

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

      982d5c

      Checking        $MESSAGE
      982d5c
      982d5c
      982d5c
      <samp>`AsCreatingLine'</samp>
      982d5c

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

      982d5c

      Creating        $MESSAGE
      982d5c
      982d5c
      982d5c
      <samp>`AsSavedAsLine'</samp>
      982d5c

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

      982d5c

      Saved as        $MESSAGE
      982d5c
      982d5c
      982d5c
      <samp>`AsLinkToLine'</samp>
      982d5c

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

      982d5c

      Linked to       $MESSAGE
      982d5c
      982d5c
      982d5c
      <samp>`AsMovedToLine'</samp>
      982d5c

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

      982d5c

      Moved to        $MESSAGE
      982d5c
      982d5c
      982d5c
      <samp>`AsTranslationLine'</samp>
      982d5c

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

      982d5c

      Translation     $MESSAGE
      982d5c
      982d5c
      982d5c
      <samp>`AsConfigurationLine'</samp>
      982d5c

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

      982d5c

      Configuration   $MESSAGE
      982d5c
      982d5c
      982d5c
      <samp>`AsResponseLine'</samp>
      982d5c

      To print response messages on one-column format.

      982d5c

      --> $MESSAGE
      982d5c
      982d5c
      982d5c
      <samp>`AsRequestLine'</samp>
      982d5c

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

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

      $MESSAGE:
      982d5c
      982d5c
      982d5c
      <samp>`AsYesOrNoRequestLine'</samp>
      982d5c

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

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

      982d5c
      $MESSAGE [y/N]:
      982d5c
      982d5c

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

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

      982d5c
      $MESSAGE [s/N]:
      982d5c
      982d5c

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

      982d5c
      <samp>`sí'</samp> word.
      982d5c

      982d5c

      Definition of which confirmation word to use is set on translation

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

      982d5c
      982d5c
      <samp>`AsToKnowMoreLine'</samp>
      982d5c

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

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

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

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

      982d5c
      script termination. 
      982d5c

      982d5c
      982d5c
      <samp>`AsRegularLine'</samp>
      982d5c

      To standardize regular messages on one-column format.

      982d5c

      982d5c

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

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

      982d5c
      982d5c
      982d5c

      Use cli_printMessage function whenever you need to output

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

      982d5c
      Info

      Tip

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

      982d5c

      trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
      982d5c
      982d5c
      010b2d
      010b2d
      010b2d
      982d5c

      2.51.3.3 Specific functions

      010b2d
      982d5c

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

      982d5c
      available for you to use:
      982d5c

      010b2d
      ee1f37
      010b2d
      982d5c

      2.51.4 See also

      ee1f37
      982d5c
      5cb5a7
      2.49 Filesystem/trunk/Scripts/Bash  
      982d5c
      982d5c
      ee1f37
      ee1f37
      ee1f37
      010b2d
      [ < ]
      56a476
      [ > ]
      ee1f37
         
      982d5c
      [ << ]
      982d5c
      [ Up ]
      5cb5a7
      [ >> ]
      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>