Blame Manuals/Repository/Filesystem/filesystem-html/repository_51.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>
1023f4
<title>CentOS Artwork Repository: 3.48 trunk/Scripts/Bash/Functions</title>
4c79b5
1023f4
<meta name="description" content="CentOS Artwork Repository: 3.48 trunk/Scripts/Bash/Functions">
1023f4
<meta name="keywords" content="CentOS Artwork Repository: 3.48 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
d11e55
[ < ]
d11e55
[ > ]
4c79b5
   
4c79b5
[ << ]
4c79b5
[ Up ]
1023f4
[ >> ]
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
[Top]
4c79b5
[Contents]
1023f4
[Index]
4c79b5
[ ? ]
4c79b5
1023f4
d11e55
1023f4

3.48 trunk/Scripts/Bash/Functions

008ee0
54b5a5
d11e55
63f275

3.48.1 Goals

54b5a5
1023f4

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

1023f4
<tt>`centos-art.sh'</tt> specific functionalities.
4a9d2a

4a9d2a
d11e55
4a9d2a

3.48.2 Description

4a9d2a
1023f4

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

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

1023f4

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

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

1023f4

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

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

1023f4

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

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

1023f4
Info

Tip

Join CentOS developers mailing list

1023f4
centos-art@centos.org to share your ideas.
1023f4

1023f4
1023f4

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

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

1023f4

OK, let's begin with our functionality example.

1023f4

1023f4

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

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

1023f4

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

1023f4

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

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

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

1023f4

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

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

1023f4

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

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

1023f4

In our greet function example, top commentary for

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

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

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

1023f4
function definition would look like the following:
1023f4

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

The first definition inside greet function, are global

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

1023f4

Later, we call greet_getActions function to define the

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

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

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

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

1023f4

The greet function definition makes available two valid

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

1023f4

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

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

1023f4

The greet_doHello and greet_doBye function definitions

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

1023f4
function greet_doHello {
1023f4
1023f4
    cli_printMessage "`gettext "Hello"` $ACTIONVAL"
1023f4
1023f4
}
1023f4
1023f4

The greet_doHello function definition is stored in

1023f4
<tt>`greet_doHello.sh'</tt> function script. 
1023f4

1023f4
function greet_doBye {
1023f4
1023f4
    cli_printMessage "`gettext "Goodbye"` $ACTIONVAL"
1023f4
1023f4
}
1023f4
1023f4

The greet_doBye function definition is stored in the

1023f4
<tt>`greet_doBye.sh'</tt> function script. 
1023f4

1023f4

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

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

1023f4

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

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

1023f4

Let's see how greet specific functionality files are organzied

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

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

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

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

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

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

1023f4
change it to have a little fun.
1023f4

1023f4

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

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

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

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

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

1023f4

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

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

1023f4
centos-art locale --edit
1023f4
1023f4
Warning

Warning

To translate output messages in different languages,

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

1023f4
1023f4

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

1023f4

1023f4

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

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

1023f4

The greet function described in this section may serve you as

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

1023f4

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

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

d11e55
d11e55
4a9d2a

3.48.3 Usage

4a9d2a
1023f4
1023f4
1023f4

3.48.3.1 Global variables

1023f4
1023f4

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

1023f4
available for you to use inside specific functions:
1023f4

1023f4
1023f4
<u>Variable:</u> TEXTDOMAIN
1023f4
1023f4
1023f4

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

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

1023f4
1023f4
1023f4
<u>Variable:</u> TEXTDOMAINDIR
1023f4
1023f4
1023f4

Default directory used to retrieve translated messages. This value is

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

1023f4
1023f4
1023f4
<u>Variable:</u> FUNCNAM
1023f4
1023f4
1023f4

Define function name.

1023f4

1023f4

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

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

1023f4

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

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

1023f4

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

1023f4
immediatly ends its execution.
1023f4

1023f4
1023f4
1023f4
<u>Variable:</u> FUNCDIR
1023f4
1023f4
1023f4
1023f4
1023f4
1023f4
<u>Variable:</u> FUNCDIRNAME
1023f4
1023f4
1023f4
1023f4
1023f4
1023f4
<u>Variable:</u> FUNCSCRIPT
1023f4
1023f4
1023f4
1023f4
1023f4
1023f4
<u>Variable:</u> FUNCCONFIG
1023f4
1023f4
1023f4
1023f4
1023f4
1023f4
<u>Variable:</u> ACTIONNAM
1023f4
1023f4
1023f4

Define action name.

1023f4

1023f4

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

1023f4
specific function.
1023f4

1023f4

Action name names aare passed as second argument in

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

1023f4

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

1023f4
immediatly ends its execution.
1023f4

1023f4
1023f4
1023f4
<u>Variable:</u> ACTIONVAL
1023f4
1023f4
1023f4

Define action value.

1023f4

1023f4

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

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

1023f4
1023f4
1023f4
<u>Variable:</u> REGEX
1023f4
1023f4
1023f4

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

1023f4
to process.
1023f4

1023f4

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

1023f4
files.
1023f4

1023f4

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

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

1023f4
1023f4
1023f4
<u>Variable:</u> ARGUMENTS
1023f4
1023f4
1023f4

Define optional arguments.

1023f4

1023f4

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

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

1023f4

Optional arguments are parsed using getopt command through

1023f4
the following base construction: 
1023f4

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

Optional arguments provide support to command options inside

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

1023f4

The ARGUMENTS variable is used to store arguments passed from

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

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

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

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

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

When getopt parses ARGUMENTS, we may use short options

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

1023f4

In order for getopt to parse ARGUMENTS correctly, it

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

1023f4

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

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

1023f4

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

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

1023f4
1023f4
1023f4
<u>Variable:</u> EDITOR
1023f4
1023f4
1023f4

Default text editor.

1023f4

1023f4

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

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

1023f4

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

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

70ef27
    1023f4
  • <tt>`/usr/bin/vim'</tt>
  • 1023f4
  • <tt>`/usr/bin/emacs'</tt>
  • 1023f4
  • <tt>`/usr/bin/nano'</tt>
  • 70ef27
    70ef27
    1023f4

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

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

    c12cdc
    1023f4
    1023f4
    1023f4

    3.48.3.2 Global functions

    1023f4
    1023f4

    Function scripts stored directly under

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

    1023f4
    1023f4
    <u>Function:</u> cli_checkActionArguments
    1023f4
    1023f4
    1023f4

    Validate action value (ACTIONVAL) variable.

    1023f4

    1023f4

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

    1023f4

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

      If another value different from that specified above is passed to

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_checkFiles FILE [TYPE]
      1023f4
      1023f4
      1023f4

      Verify file existence.

      1023f4

      1023f4

      cli_checkFiles receives a FILE absolute path and performs

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

      1023f4
      1023f4
      <samp>`d'</samp>
      1023f4
      <samp>`directory'</samp>
      1023f4

      Ends script execution if FILE is not a directory.

      1023f4

      1023f4

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

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

      1023f4
      1023f4
      <samp>`f'</samp>
      1023f4
      <samp>`regular-file'</samp>
      1023f4

      Ends script execution if FILE is not a regular file.

      1023f4

      1023f4
      <samp>`h'</samp>
      1023f4
      <samp>`symbolic-link'</samp>
      1023f4

      Ends script execution if FILE is not a symbolic link.

      1023f4

      1023f4
      <samp>`x'</samp>
      1023f4
      <samp>`execution'</samp>
      1023f4

      Ends script execution if FILE is not executable.

      1023f4

      1023f4
      <samp>`fh'</samp>
      1023f4

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

      1023f4
      symbolic link.
      1023f4

      1023f4
      <samp>`fd'</samp>
      1023f4

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

      1023f4
      directory.
      1023f4

      1023f4
      <samp>`isInWorkingCopy'</samp>
      1023f4

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

      1023f4

      1023f4
      1023f4
      1023f4

      As default behaviour, if FILE passes all verifications,

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_commitRepoChanges [LOCATION]
      1023f4
      1023f4
      1023f4

      Syncronize changes between repository and working copy.

      1023f4

      1023f4

      The cli_commitRepoChanges function brings changes from the

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

      1023f4

      Previous to commit the working copy changes up to the central

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

      1023f4

      If LOCATION argument is not specified, the value of

      1023f4
      ACTIONVAL variable is used as reference instead.
      1023f4

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

      Figure 3.3: The cli_commitRepoChanges function output.

      1023f4
      1023f4

      1023f4

      Call the cli_commitRepoChanges function before or/and after

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_doParseArguments
      1023f4
      1023f4
      1023f4

      Redefine arguments (ARGUMENTS) global variable using

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_doParseArgumentsReDef $@
      1023f4
      1023f4
      1023f4

      Initialize/reset arguments (ARGUMENTS) global variable using

      1023f4
      positional parameters variable ($@) as reference.
      1023f4

      1023f4

      When we work inside function definitions, positional parameters are

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_getArguments
      1023f4
      1023f4
      1023f4

      Initialize function name (FUNCNAM), action name

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

      1023f4

      The cli_getArguments function is called from cli.sh

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

      1023f4

      Once command-line positional parameters are accesible to

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

      1023f4

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

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

      1023f4

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

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

      1023f4

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

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_getFunctions
      1023f4
      1023f4
      1023f4

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

      1023f4

      1023f4

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

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

      1023f4

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

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

      1023f4

      Inside each functionality directory, the functionalty itself is

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

      1023f4

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

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

      1023f4
      function prefix_doSomething {
      1023f4
      1023f4
          # Do something here...
      1023f4
      1023f4
      }
      1023f4
      1023f4

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

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

      1023f4

      If the functionality specified in the command-line first argument

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

      1023f4

      In order to keep visual consistency among function scripts, please

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

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

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

      1023f4

      1023f4

      The cli_getCountryCodes function outputs a list with country

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_getCountryName [FILTER]
      1023f4
      1023f4
      1023f4

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

      1023f4

      1023f4

      The cli_getCountryName function reads one language locale code

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

      1023f4
       
      1023f4
      1023f4
      <u>Function:</u> cli_getCurrentLocale
      1023f4
      1023f4
      1023f4

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

      1023f4

      1023f4

      The cli_getCurrentLocale function uses LANG environment

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

      1023f4

      The current locale information, returned by

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

      1023f4

      Locale precedence selection is quite important in order to define the

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

      1023f4

      Use cli_getCurrentLocale function to know what current locale

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_getFilesList [LOCATION]
      1023f4
      1023f4
      1023f4

      Output list of files to process.

      1023f4

      1023f4

      The cli_getFilesList function uses LOCATION variable as

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

      1023f4

      If LOCATION is not specified when cli_getFilesList

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

      1023f4

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

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

      1023f4

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

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

      1023f4

      As result, the cli_getFilesList re-defines the value of

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

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

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

      1023f4

      1023f4

      cli_getLangCodes function outputs a list of language codes as

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_getLangName [FILTER]
      1023f4
      1023f4
      1023f4

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

      1023f4

      1023f4

      cli_getLangName function reads one language locale code in the

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_getLocales
      1023f4
      1023f4
      1023f4

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

      1023f4

      1023f4

      Occasionally, you use cli_getLocales function to add locale

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_getRepoName NAME TYPE
      1023f4
      1023f4
      1023f4

      Sanitate file names.

      1023f4

      1023f4

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

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

      1023f4
      Important

      Important

      cli_getRepoName function doesn't verify file

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

      1023f4
      1023f4

      The NAME variable contains the file name or directory name you

      1023f4
      want to sanitate.
      1023f4

      1023f4

      The TYPE variable specifies what type of sanitation you want to

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

      1023f4
      1023f4
      <samp>`d'</samp>
      1023f4
      <samp>`directory'</samp>
      1023f4

      Sanitate directory NAMEs.

      1023f4

      1023f4
      <samp>`f'</samp>
      1023f4
      <samp>`regular-file'</samp>
      1023f4

      Sanitate regular file NAMEs.

      1023f4

      1023f4
      1023f4
      1023f4

      Use cli_getRepoName function to sanitate file names and

      1023f4
      directory names before their utilization. 
      1023f4

      1023f4

      Use cli_getRepoName when you need to change file name

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

      1023f4

      When we change file name convenctions inside cli_getRepoName

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_getRepoStatus [LOCATION]
      1023f4
      1023f4
      1023f4

      Request repository status.

      1023f4

      1023f4

      This function requests the status of a LOCATION inside the

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

      1023f4

      Use this function to perform verifications based a repository

      1023f4
      LOCATION status.
      1023f4

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_getTemporalFile NAME
      1023f4
      1023f4
      1023f4

      Output absolute path to temporal file NAME.

      1023f4

      1023f4

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

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

      1023f4
      cli_getTemporalFile $FILE
      1023f4
      1023f4

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

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

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

      When you use the cli_getTemporalFile function to create

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

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

      Use the cli_getTemporalFile function whenever you need to

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_getThemeName
      1023f4
      1023f4
      1023f4

      Output theme name.

      1023f4

      1023f4

      In order for cli_getThemeName function to extract theme name

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

      1023f4
      1023f4
      1023f4
      <u>Function:</u> cli_printMessage MESSAGE [FORMAT]
      1023f4
      1023f4
      1023f4

      Define standard output message definition supported by

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

      1023f4

      When FORMAT is not specified, cli_printMessage outputs

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

      1023f4
      1023f4
      <samp>`AsHeadingLine'</samp>
      1023f4

      To print heading messages.

      1023f4

      ----------------------------------------------------------------------
      1023f4
      $MESSAGE
      1023f4
      ----------------------------------------------------------------------
      1023f4
      1023f4
      1023f4
      <samp>`AsWarningLine'</samp>
      1023f4

      To print warning messages.

      1023f4

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

      To print note messages.

      1023f4

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

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

      1023f4

      Updating        $MESSAGE
      1023f4
      1023f4
      1023f4
      <samp>`AsRemovingLine'</samp>
      1023f4

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

      1023f4

      Removing        $MESSAGE
      1023f4
      1023f4
      1023f4
      <samp>`AsCheckingLine'</samp>
      1023f4

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

      1023f4

      Checking        $MESSAGE
      1023f4
      1023f4
      1023f4
      <samp>`AsCreatingLine'</samp>
      1023f4

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

      1023f4

      Creating        $MESSAGE
      1023f4
      1023f4
      1023f4
      <samp>`AsSavedAsLine'</samp>
      1023f4

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

      1023f4

      Saved as        $MESSAGE
      1023f4
      1023f4
      1023f4
      <samp>`AsLinkToLine'</samp>
      1023f4

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

      1023f4

      Linked to       $MESSAGE
      1023f4
      1023f4
      1023f4
      <samp>`AsMovedToLine'</samp>
      1023f4

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

      1023f4

      Moved to        $MESSAGE
      1023f4
      1023f4
      1023f4
      <samp>`AsTranslationLine'</samp>
      1023f4

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

      1023f4

      Translation     $MESSAGE
      1023f4
      1023f4
      1023f4
      <samp>`AsConfigurationLine'</samp>
      1023f4

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

      1023f4

      Configuration   $MESSAGE
      1023f4
      1023f4
      1023f4
      <samp>`AsResponseLine'</samp>
      1023f4

      To print response messages on one-column format.

      1023f4

      --> $MESSAGE
      1023f4
      1023f4
      1023f4
      <samp>`AsRequestLine'</samp>
      1023f4

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

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

      $MESSAGE:
      1023f4
      1023f4
      1023f4
      <samp>`AsYesOrNoRequestLine'</samp>
      1023f4

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

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

      1023f4
      $MESSAGE [y/N]:
      1023f4
      1023f4

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

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

      1023f4
      $MESSAGE [s/N]:
      1023f4
      1023f4

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

      1023f4
      <samp>`sí'</samp> word.
      1023f4

      1023f4

      Definition of which confirmation word to use is set on translation

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

      1023f4
      1023f4
      <samp>`AsToKnowMoreLine'</samp>
      1023f4

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

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

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

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

      1023f4
      script termination. 
      1023f4

      1023f4
      1023f4
      <samp>`AsRegularLine'</samp>
      1023f4

      To standardize regular messages on one-column format.

      1023f4

      1023f4

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

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

      1023f4
      1023f4
      1023f4

      Use cli_printMessage function whenever you need to output

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

      1023f4
      Info

      Tip

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

      1023f4

      trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
      1023f4
      1023f4
      1023f4
      1023f4
      1023f4
      1023f4

      3.48.3.3 Specific functions

      1023f4
      1023f4

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

      1023f4
      available for you to use:
      1023f4

      1023f4
      1023f4
      3.49 trunk/Scripts/Bash/Functions/Html  
      1023f4
      1023f4
      3.50 trunk/Scripts/Bash/Functions/Locale  
      1023f4
      1023f4
      3.51 trunk/Scripts/Bash/Functions/Manual  
      1023f4
      1023f4
      3.52 trunk/Scripts/Bash/Functions/Path  
      1023f4
      1023f4
      3.53 trunk/Scripts/Bash/Functions/Render  
      1023f4
      1023f4
      3.54 trunk/Scripts/Bash/Functions/Render/Config  
      1023f4
      1023f4
      3.55 trunk/Scripts/Bash/Functions/Shell  
      1023f4
      1023f4
      3.56 trunk/Scripts/Bash/Functions/Svg  
      1023f4
      1023f4
      3.57 trunk/Scripts/Bash/Functions/Verify  
      1023f4
      1023f4
      1023f4
      1023f4
      1023f4
      c12cdc

      3.48.4 See also

      c12cdc
      1023f4
      1023f4
      3.47 trunk/Scripts/Bash  
      1023f4
      1023f4
      3.58 trunk/Scripts/Bash/Locale  
      1023f4
      1023f4
      4c79b5
      4c79b5
      4c79b5
      1023f4
      [ < ]
      1023f4
      [ > ]
      4c79b5
         
      4c79b5
      [ << ]
      d11e55
      [ Up ]
      1023f4
      [ >> ]
      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>