Blame Manuals/en/Html/Repository/repository_38.html

4c79b5
4c79b5
<html>
4c79b5
4c79b5
can you do inside it.
4c79b5
6c4982
Copyright C 2009, 2010 Alain Reguera Delgado. All rights
4c79b5
reserved.
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
-->
915635
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>
54264c
<title>CentOS Artwork Repository: 3.35 trunk/Scripts/Bash/Functions</title>
4c79b5
54264c
<meta name="description" content="CentOS Artwork Repository: 3.35 trunk/Scripts/Bash/Functions">
54264c
<meta name="keywords" content="CentOS Artwork Repository: 3.35 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
efa7b7
[ < ]
efa7b7
[ > ]
4c79b5
   
4c79b5
[ << ]
4c79b5
[ Up ]
915635
[ >> ]
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
[Top]
4c79b5
[Contents]
915635
[Index]
4c79b5
[ ? ]
4c79b5
54264c
efa7b7
54264c

3.35 trunk/Scripts/Bash/Functions

5fb024
5fb024
efa7b7
5fb024

3.35.1 Goals

5fb024
6c4982

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

6c4982
<tt>`centos-art.sh'</tt> specific functionalities.
6c4982

5fb024
efa7b7
5fb024

3.35.2 Description

5fb024
6c4982

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

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

6c4982

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

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

6c4982

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

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

2bb528

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

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

be6bef
Info

Tip

Join CentOS developers mailing list

2bb528
centos-art@centos.org to share your ideas.
6c4982

5fb024
915635

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

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

2bb528

OK, let's begin with our functionality example.

6c4982

be6bef

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

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

be6bef

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

6c4982

6c4982
Name: greet
6c4982
Path: trunk/Scripts/Bash/Functions/Greet
6c4982
File: trunk/Scripts/Bash/Functions/Greet/greet.sh
6c4982
41f1ec

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

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

2bb528

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

2bb528
script has one top commentary, followed by one blank line, and then
2bb528
one function defintion below it only.
6c4982

915635

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

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

2bb528

In our greet function example, top commentary for

2bb528
<tt>`greet.sh'</tt> function script would look like the following:
6c4982

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

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

2bb528
function definition would look like the following:
6c4982

6c4982
function greet {
6c4982
6c4982
    # Define global variables.
6c4982
6c4982
    # Define command-line interface.
6c4982
    greet_getActions
6c4982
6c4982
}
6c4982
41f1ec

The first definition inside greet function, are global

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

41f1ec

Later, we call greet_getActions function to define the

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

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

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

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

2bb528

The greet function definition makes available two valid

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

41f1ec

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

41f1ec
in <tt>`_getActions.sh'</tt> function scripts, no matter what specific
41f1ec
functionality you are creating. This convenction helps the user to
41f1ec
find out documentation about current functionality in use.  
41f1ec

41f1ec

The greet_doHello and greet_doBye function definitions

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

6c4982
function greet_doHello {
6c4982
6c4982
    cli_printMessage "`gettext "Hello"` $OPTIONVAL"
6c4982
6c4982
}
6c4982
be6bef

The greet_doHello function definition is stored in

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

6c4982
function greet_doBye {
6c4982
6c4982
    cli_printMessage "`gettext "Goodbye"` $OPTIONVAL"
6c4982
6c4982
}
6c4982
be6bef

The greet_doBye function definition is stored in the

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

be6bef

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

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

41f1ec

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

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

be6bef

Let's see how greet specific functionality files are organzied

41f1ec
under greet's function directory. To see file organization we
be6bef
use the tree command:
6c4982

6c4982
trunk/Scripts/Bash/Functions/Greet
6c4982
|-- greet_doBye.sh
6c4982
|-- greet_doHello.sh
6c4982
|-- greet_getActions.sh
6c4982
`-- greet.sh
6c4982
2bb528

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

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

6c4982
[centos@projects ~]$ centos-art greet --hello='World'
6c4982
Hello World
6c4982
[centos@projects ~]$ centos-art greet --bye='World'
6c4982
Goodbye World
6c4982
[centos@projects ~]$ 
6c4982
41f1ec

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

41f1ec
change it to have a little fun.
be6bef

be6bef

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

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

be6bef
centos-art help --edit=trunk/Scripts/Bash/Functions/Greet
be6bef
41f1ec

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

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

41f1ec
centos-art locale --edit
41f1ec
41f1ec
Warning

Warning

To translate output messages in different languages,

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

41f1ec
be6bef

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

be6bef

41f1ec

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

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

2bb528

The greet function described in this section may serve you as

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

be6bef

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

41f1ec
<tt>`centos-art.sh'</tt> script yet. Would you like to create it?
6c4982

6c4982
be6bef
5fb024

3.35.3 Usage

5fb024
6c4982
be6bef
6c4982

3.35.3.1 Global variables

6c4982
6c4982

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

6c4982
available for you to use inside specific functions:
6c4982

be6bef
be6bef
<u>Variable:</u> TEXTDOMAIN
be6bef
be6bef
6c4982

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

2bb528
in <tt>`initFunctions.sh'</tt> and shouldn't be changed.
be6bef

be6bef
be6bef
be6bef
<u>Variable:</u> TEXTDOMAINDIR
be6bef
be6bef
6c4982

Default directory used to retrieve translated messages. This value is

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

be6bef
be6bef
be6bef
<u>Variable:</u> ACTION
be6bef
be6bef
2bb528

Default action passed as first argument in <tt>`centos-art.sh'</tt>

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

be6bef
be6bef
be6bef
<u>Variable:</u> OPTIONNAM
be6bef
be6bef
2bb528

Default option name passed as second argument in <tt>`centos-art.sh'</tt>

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

be6bef
be6bef
be6bef
<u>Variable:</u> OPTIONVAL
be6bef
be6bef
2bb528

Default option value passed as second argument in <tt>`centos-art.sh'</tt>

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

be6bef
be6bef
be6bef
<u>Variable:</u> REGEX
be6bef
be6bef
2bb528

Default option value passed as third argument in <tt>`centos-art.sh'</tt>

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

2bb528

The third argument option name is not variable as second argument

915635
option name is. The third argument option name is fixed to
915635
<samp>`--filter'</samp> for whatever value it passes at the right side of
2bb528
its equal sign. 
2bb528

2bb528

Generally, third argument option value is used to pass regular

2bb528
expression patterns that modify the list of files to process, but this
915635
is not the only feature REGEX global variable may serve to.
be6bef

be6bef
be6bef
be6bef
<u>Variable:</u> EDITOR
915635
be6bef
2bb528

Default text editor.

2bb528

2bb528

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

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

2bb528

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

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

6c4982
    2bb528
  • <tt>`/usr/bin/vim'</tt>
  • 2bb528
  • <tt>`/usr/bin/emacs'</tt>
  • 2bb528
  • <tt>`/usr/bin/nano'</tt>
  • 6c4982
    2bb528
    2bb528

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

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

    6c4982
    6c4982
    be6bef
    6c4982

    3.35.3.2 Global functions

    6c4982
    6c4982

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

    6c4982
    available for you to use inside specific functions:
    6c4982

    be6bef
    be6bef
    <u>Function:</u> cli_commitRepoChanges
    915635
    be6bef
    06048d

    Commit changes from the working copy up to the repository.

    2bb528

    915635

    The cli_commitRepoChanges function uses the value of

    06048d
    OPTIONVAL variable as reference to perform change verifications
    0646d4
    inside the working copy.
    06048d

    06048d

    The cli_commitRepoChanges function brings changes from the

    06048d
    repository to the working copy--using svn update--, check
    06048d
    the working copy changes--using svn status command--,
    06048d
    print status report--using both svn update and svn
    06048d
    status commands output, and finally, commit recent changes from the
    06048d
    working copy up to the repository--using svn commit
    06048d
    command--.
    06048d

    06048d

    Previous to commit the working copy changes up to the repository, the

    06048d
    cli_commitRepoChanges function asks you to verify changes, and
    06048d
    later, another confirmation question is shown to be sure you really
    06048d
    want to commit changes up to central repository.
    06048d

    0646d4

    Call the cli_commitRepoChanges function after functions that

    0646d4
    modify files or directories inside the working copy.  
    2bb528

    be6bef
    be6bef
    2bb528
    <u>Function:</u> cli_checkFiles FILE [TYPE]
    915635
    be6bef
    915635

    Verify files existence.

    be6bef

    2bb528

    cli_checkFiles receives a FILE absolute path and performs

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

    6c4982
    be6bef
    <samp>`d'</samp>
    be6bef
    <samp>`directory'</samp>
    2bb528

    Ends script execution if FILE is not a directory.

    2bb528

    2bb528

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

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

    2bb528
    be6bef
    <samp>`f'</samp>
    be6bef
    <samp>`regular-file'</samp>
    2bb528

    Ends script execution if FILE is not a regular file.

    be6bef

    be6bef
    <samp>`h'</samp>
    be6bef
    <samp>`symbolic-link'</samp>
    2bb528

    Ends script execution if FILE is not a symbolic link.

    2bb528

    2bb528
    <samp>`x'</samp>
    2bb528
    <samp>`execution'</samp>
    2bb528

    Ends script execution if FILE is not executable.

    be6bef

    be6bef
    <samp>`fh'</samp>
    2bb528

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

    2bb528
    symbolic link.
    be6bef

    be6bef
    be6bef
    2bb528

    As default behaviour, if FILE passes all verifications,

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

    be6bef
    be6bef
    be6bef
    <u>Function:</u> cli_getCountryCodes [FILTER]
    915635
    be6bef
    2bb528

    Output country codes.

    2bb528

    2bb528

    The cli_getCountryCodes function outputs a list with country

    2bb528
    codes as defined in ISO3166 standard. When FILTER is provided,
    41f1ec
    cli_getCountryCodes outputs country codes that match
    be6bef
    FILTER regular expression pattern.
    be6bef

    be6bef
    be6bef
    2bb528
    <u>Function:</u> cli_getCountryName [FILTER]
    915635
    be6bef
    2bb528

    Output country names.

    2bb528

    2bb528

    The cli_getCountryName function reads one language locale code

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

    2bb528

    The cli_getCountryName function outputs country name supported

    2bb528
    by <tt>`centos-art.sh'</tt> script.
    be6bef

    be6bef
     
    be6bef
    be6bef
    <u>Function:</u> cli_getCurrentLocale
    915635
    be6bef
    2bb528

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

    2bb528

    2bb528

    The cli_getCurrentLocale function uses LANG environment

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

    41f1ec

    The current locale information, returned by

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

    41f1ec

    Locale precedence selection is quite important in order to define the

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

    41f1ec

    Use cli_getCurrentLocale function to know what current locale

    41f1ec
    information to use inside <tt>`centos-art.sh'</tt> script.
    2bb528

    2bb528

    The cli_getCurrentLocale function outputs current locale used

    2bb528
    by <tt>`centos-art.sh'</tt> script.
    be6bef

    be6bef
    be6bef
    be6bef
    <u>Function:</u> cli_getLangCodes [FILTER]
    915635
    be6bef
    2bb528

    Output language codes.

    2bb528

    2bb528

    cli_getLangCodes function outputs a list of language codes as

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

    2bb528

    The cli_getLangCodes function outputs language codes supported

    2bb528
    by <tt>`centos-art.sh'</tt> script.
    be6bef

    be6bef
    be6bef
    41f1ec
    <u>Function:</u> cli_getLangName [FILTER]
    915635
    be6bef
    2bb528

    Output language names.

    2bb528

    2bb528

    cli_getLangName function reads one language locale code in the

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

    2bb528

    The cli_getLangName function outputs language names supported

    2bb528
    by <tt>`centos-art.sh'</tt> script.
    be6bef

    be6bef
    be6bef
    be6bef
    <u>Function:</u> cli_getLocales
    915635
    be6bef
    2bb528

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

    41f1ec

    41f1ec

    Occasionally, you use cli_getLocales function to add locale

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

    be6bef
    be6bef
    41f1ec
    <u>Function:</u> cli_getRepoName NAME TYPE
    915635
    be6bef
    2bb528

    Sanitate file names.

    2bb528

    2bb528

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

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

    915635
    Important

    Important

    cli_getRepoName function doesn't verify file

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

    41f1ec
    41f1ec

    The NAME variable contains the file name or directory name you

    41f1ec
    want to sanitate.
    41f1ec

    41f1ec

    The TYPE variable can be one of the following values:

    41f1ec

    41f1ec
    <samp>`d'</samp>
    41f1ec
    <samp>`directory'</samp>
    41f1ec

    Sanitate directory NAMEs.

    41f1ec

    41f1ec
    <samp>`f'</samp>
    41f1ec
    <samp>`regular-file'</samp>
    41f1ec

    Sanitate regular file NAMEs.

    41f1ec

    41f1ec
    41f1ec
    41f1ec

    Use cli_getRepoName function to sanitate file names and

    41f1ec
    directory names before their utilization. 
    41f1ec

    41f1ec

    Use cli_getRepoName when you need to change file name

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

    2bb528

    When changing file name convenctions inside cli_getRepoName

    2bb528
    what you are really changing is the way functions interpret repository
    2bb528
    file system organization. In order to a complete file name convenction
    2bb528
    change, you also need to change file names and directory names inside
    2bb528
    repository file system organization, just as you did in
    2bb528
    cli_getRepoName function. 
    41f1ec

    41f1ec
    info

    Note

    See section trunk/Scripts/Bash/Functions/Path, for more

    41f1ec
    information on how to rename files and directories massively inside
    41f1ec
    repository file system organization.
    41f1ec

    41f1ec
    be6bef
    be6bef
    915635
    <u>Function:</u> cli_getTemporalFile NAME
    915635
    915635
    915635

    Output absolute path to temporal file NAME.

    915635

    915635

    cli_getTemporalFile uses <tt>`/tmp'</tt> directory as source

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

    915635
    cli_getTemporalFile $FILE
    915635
    915635

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

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

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

    When you use cli_getTemporalFile function to create temporal

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

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

    Use cli_getTemporalFile function whenever you need to create

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

    915635
    915635
    be6bef
    <u>Function:</u> cli_getThemeName
    915635
    be6bef
    2bb528

    Output theme name.

    2bb528

    2bb528

    In order for cli_getThemeName function to extract theme name

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

    be6bef
    be6bef
    be6bef
    <u>Function:</u> cli_printMessage MESSAGE [FORMAT]
    915635
    be6bef
    2bb528

    Give format to output messages.

    be6bef

    be6bef

    When FORMAT is not specified, cli_printMessage outputs

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

    be6bef
    be6bef
    <samp>`AsHeadingLine'</samp>
    2bb528

    To print heading messages.

    be6bef

    ----------------------------------------------------------------------
    be6bef
    $MESSAGE
    be6bef
    ----------------------------------------------------------------------
    be6bef
    6c4982
    be6bef
    <samp>`AsWarningLine'</samp>
    2bb528

    To print warning messages.

    be6bef

    ----------------------------------------------------------------------
    be6bef
    WARNING: $MESSAGE
    be6bef
    ----------------------------------------------------------------------
    be6bef
    6c4982
    be6bef
    <samp>`AsNoteLine'</samp>
    2bb528

    To print note messages.

    be6bef

    ----------------------------------------------------------------------
    be6bef
    NOTE: $MESSAGE
    be6bef
    ----------------------------------------------------------------------
    be6bef
    6c4982
    be6bef
    <samp>`AsUpdatingLine'</samp>
    2bb528

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

    be6bef

    Updating        $MESSAGE
    be6bef
    6c4982
    be6bef
    <samp>`AsRemovingLine'</samp>
    2bb528

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

    be6bef

    Removing        $MESSAGE
    be6bef
    6c4982
    be6bef
    <samp>`AsCheckingLine'</samp>
    2bb528

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

    be6bef

    Checking        $MESSAGE
    be6bef
    6c4982
    be6bef
    <samp>`AsCreatingLine'</samp>
    2bb528

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

    be6bef

    Creating        $MESSAGE
    be6bef
    be6bef
    be6bef
    <samp>`AsSavedAsLine'</samp>
    2bb528

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

    be6bef

    Saved as        $MESSAGE
    be6bef
    6c4982
    be6bef
    <samp>`AsLinkToLine'</samp>
    2bb528

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

    be6bef

    Linked to       $MESSAGE
    be6bef
    be6bef
    be6bef
    <samp>`AsMovedToLine'</samp>
    2bb528

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

    be6bef

    Moved to        $MESSAGE
    be6bef
    be6bef
    be6bef
    <samp>`AsTranslationLine'</samp>
    2bb528

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

    be6bef

    Translation     $MESSAGE
    be6bef
    be6bef
    be6bef
    <samp>`AsConfigurationLine'</samp>
    2bb528

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

    be6bef

    Configuration   $MESSAGE
    be6bef
    be6bef
    be6bef
    <samp>`AsResponseLine'</samp>
    2bb528

    To print response messages using one-column format.

    be6bef

    --> $MESSAGE
    be6bef
    be6bef
    be6bef
    <samp>`AsRequestLine'</samp>
    2bb528

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

    2bb528
    supress the trailing newline character from final output.
    be6bef

    $MESSAGE
    be6bef
    be6bef
    be6bef
    <samp>`AsYesOrNoRequestLine'</samp>
    2bb528

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

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

    be6bef
    $MESSAGE [y/N]:
    be6bef
    be6bef

    When you are using <tt>`centos-art.sh'</tt> script in a locale different

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

    be6bef
    $MESSAGE [s/N]:
    be6bef
    be6bef

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

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

    be6bef

    Definition of which confirmation word to use is set on translation

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

    6c4982
    be6bef
    <samp>`AsToKnowMoreLine'</samp>
    2bb528

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

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

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

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

    be6bef
    script termination. 
    6c4982

    6c4982
    be6bef
    <samp>`AsRegularLine'</samp>
    be6bef

    To standardize regular messages using one-column format.

    be6bef

    be6bef

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

    be6bef
    message'</samp>), the cli_printMessage function outputs MESSAGE
    be6bef
    using two-columns format. 
    6c4982

    6c4982
    2bb528
    2bb528
    Info

    Tip

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

    2bb528

    trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
    2bb528
    2bb528
    41f1ec

    Use cli_printMessage function whenever you need to output

    2bb528
    information from <tt>`centos-art.sh'</tt> script.
    41f1ec

    6c4982
    6c4982
    be6bef
    6c4982

    3.35.3.3 Specific functions

    6c4982
    6c4982

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

    6c4982
    available for you to use:
    6c4982

    6c4982
    be6bef
    3.36 trunk/Scripts/Bash/Functions/Help  
    38bcd9
    be6bef
    3.37 trunk/Scripts/Bash/Functions/Html  
    38bcd9
    be6bef
    3.38 trunk/Scripts/Bash/Functions/Locale  
    38bcd9
    be6bef
    3.39 trunk/Scripts/Bash/Functions/Path  
    38bcd9
    be6bef
    3.40 trunk/Scripts/Bash/Functions/Render  
    38bcd9
    be6bef
    3.41 trunk/Scripts/Bash/Functions/Render/Config  
    b17ce8
    be6bef
    3.42 trunk/Scripts/Bash/Functions/Shell  
    38bcd9
    be6bef
    3.43 trunk/Scripts/Bash/Functions/Svg  
    38bcd9
    915635
    3.44 trunk/Scripts/Bash/Functions/Verify  
    38bcd9
    38bcd9
    5fb024
    5fb024
    be6bef
    5fb024

    3.35.4 See also

    4c79b5
    54264c
    38bcd9
    3.34 trunk/Scripts/Bash  
    54264c
    915635
    3.45 trunk/Scripts/Bash/Locale  
    efa7b7
    54264c
    4c79b5
    4c79b5
    4c79b5
    be6bef
    [ < ]
    be6bef
    [ > ]
    4c79b5
       
    4c79b5
    [ << ]
    efa7b7
    [ Up ]
    915635
    [ >> ]
    4c79b5
    4c79b5

    4c79b5
     <font size="-1">
    915635
      This document was generated on November, 10 2010 using texi2html 1.76.
    4c79b5
     </font>
    4c79b5
     
    4c79b5
    4c79b5

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