|
|
010b2d |
|
|
|
010b2d |
<html>
|
|
|
d1db00 |
|
|
|
d1db00 |
organization, and administration of CentOS Artwork Repository.
|
|
|
d1db00 |
|
|
|
d1db00 |
Copyright C 2009-2011 Alain Reguera Delgado
|
|
|
010b2d |
|
|
|
010b2d |
Permission is granted to copy, distribute and/or modify this document
|
|
|
010b2d |
under the terms of the GNU Free Documentation License, Version 1.2 or
|
|
|
010b2d |
any later version published by the Free Software Foundation; with no
|
|
|
010b2d |
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
|
|
|
010b2d |
copy of the license is included in the section entitled GNU Free
|
|
|
010b2d |
Documentation License.
|
|
|
010b2d |
-->
|
|
|
632e8b |
|
|
|
010b2d |
|
|
|
010b2d |
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
|
|
|
010b2d |
Karl Berry <karl@freefriends.org>
|
|
|
010b2d |
Olaf Bachmann <obachman@mathematik.uni-kl.de>
|
|
|
010b2d |
and many others.
|
|
|
010b2d |
Maintained by: Many creative people <dev@texi2html.cvshome.org>
|
|
|
010b2d |
Send bugs and suggestions to <users@texi2html.cvshome.org>
|
|
|
010b2d |
|
|
|
010b2d |
-->
|
|
|
010b2d |
<head>
|
|
|
632e8b |
<title>CentOS Artwork Repository: 2.62 The trunk/Scripts/Bash/Cli/Functions Directory</title>
|
|
|
010b2d |
|
|
|
632e8b |
<meta name="description" content="CentOS Artwork Repository: 2.62 The trunk/Scripts/Bash/Cli/Functions Directory">
|
|
|
632e8b |
<meta name="keywords" content="CentOS Artwork Repository: 2.62 The trunk/Scripts/Bash/Cli/Functions Directory">
|
|
|
010b2d |
<meta name="resource-type" content="document">
|
|
|
010b2d |
<meta name="distribution" content="global">
|
|
|
010b2d |
<meta name="Generator" content="texi2html 1.76">
|
|
|
010b2d |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
|
010b2d |
<style type="text/css">
|
|
|
010b2d |
|
|
|
010b2d |
@import "/home/centos/artwork/trunk/Identity/Models/Css/Texi2html/common.css";
|
|
|
010b2d |
|
|
|
010b2d |
a.summary-letter {text-decoration: none}
|
|
|
010b2d |
pre.display {font-family: serif}
|
|
|
010b2d |
pre.format {font-family: serif}
|
|
|
010b2d |
pre.menu-comment {font-family: serif}
|
|
|
010b2d |
pre.menu-preformatted {font-family: serif}
|
|
|
010b2d |
pre.smalldisplay {font-family: serif; font-size: smaller}
|
|
|
010b2d |
pre.smallexample {font-size: smaller}
|
|
|
010b2d |
pre.smallformat {font-family: serif; font-size: smaller}
|
|
|
010b2d |
pre.smalllisp {font-size: smaller}
|
|
|
010b2d |
span.sansserif {font-family:sans-serif; font-weight:normal;}
|
|
|
010b2d |
ul.toc {list-style: none}
|
|
|
010b2d |
-->
|
|
|
010b2d |
</style>
|
|
|
010b2d |
|
|
|
010b2d |
|
|
|
010b2d |
</head>
|
|
|
010b2d |
|
|
|
010b2d |
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
|
|
|
010b2d |
|
|
|
010b2d |
|
|
|
632e8b |
[ < ]
|
|
|
632e8b |
[ > ]
|
|
|
010b2d |
|
|
|
671838 |
[ << ]
|
|
|
671838 |
[ Up ]
|
|
|
632e8b |
[ >> ]
|
|
|
010b2d |
|
|
|
010b2d |
|
|
|
010b2d |
|
|
|
010b2d |
|
|
|
982d5c |
[Top]
|
|
|
982d5c |
[Contents]
|
|
|
632e8b |
[Index]
|
|
|
982d5c |
[ ? ]
|
|
|
010b2d |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
2.62 The <tt>`trunk/Scripts/Bash/Cli/Functions'</tt> Directory
|
|
|
671838 |
|
|
|
671838 |
|
|
|
632e8b |
|
|
|
671838 |
2.62.1 Goals
|
|
|
671838 |
|
|
|
632e8b |
The <tt>`trunk/Scripts/Bash/Functions'</tt> directory exists to organize
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> specific functionalities.
|
|
|
671838 |
|
|
|
671838 |
|
|
|
632e8b |
|
|
|
671838 |
2.62.2 Description
|
|
|
063806 |
|
|
|
632e8b |
The specific functions of <tt>`centos-art.sh'</tt> script are designed
|
|
|
632e8b |
with "Software Toolbox" philosophy (see (coreutils.info)Toolbox introduction) in mind: each program "should do one
|
|
|
632e8b |
thing well". Inside <tt>`centos-art.sh'</tt> script, each specific
|
|
|
632e8b |
functionality is considered a program that should do one thing well.
|
|
|
632e8b |
Of course, if you find that they still don't do it, feel free to
|
|
|
632e8b |
improve them in order for them to do so.
|
|
|
632e8b |
|
|
|
632e8b |
The specific functions of <tt>`centos-art.sh'</tt> script are organized
|
|
|
632e8b |
inside specific directories under <tt>`trunk/Scripts/Bash/Functions'</tt>
|
|
|
632e8b |
location. Each specific function directory should be named as the
|
|
|
632e8b |
function it represents, with the first letter in uppercase. For
|
|
|
632e8b |
example, if the function name is render , the specific function
|
|
|
632e8b |
directory for it would be <samp>`trunk/Scripts/Bash/Functions/Render'</samp>.
|
|
|
632e8b |
|
|
|
632e8b |
To better understand how specific functions of <tt>`centos-art.sh'</tt>
|
|
|
632e8b |
script are designed, lets create one function which only goal is to
|
|
|
632e8b |
output different kind of greetings to your screen.
|
|
|
632e8b |
|
|
|
632e8b |
When we create specific functions for <tt>`centos-art.sh'</tt> script it
|
|
|
632e8b |
is crucial to know what these functions will do exactly and if there
|
|
|
632e8b |
is any function that already does what we intend to do. If there is no
|
|
|
632e8b |
one, it is good time to create them then. Otherwise, if
|
|
|
632e8b |
functionalities already available don't do what you exactly expect,
|
|
|
632e8b |
contact their authors and work together to improve them.
|
|
|
632e8b |
|
|
|
632e8b |
Tip Join CentOS developers mailing list
|
|
|
632e8b |
centos-art@centos.org to share your ideas.
|
|
|
671838 |
|
|
|
671838 |
|
|
|
632e8b |
It is also worth to know what global functions and variables do we
|
|
|
632e8b |
have available inside <tt>`centos-art.sh'</tt> script, so advantage can be
|
|
|
632e8b |
taken from them. Global variables are defined inside global function
|
|
|
632e8b |
scripts. Global functions scripts are stored immediatly under
|
|
|
632e8b |
<tt>`trunk/Scripts/Bash/Functions'</tt> directory, in files begining with
|
|
|
632e8b |
<samp>`cli'</samp> prefix.
|
|
|
063806 |
|
|
|
632e8b |
OK, let's begin with our functionality example.
|
|
|
632e8b |
|
|
|
632e8b |
What function name do we use? Well, lets use greet . Note that
|
|
|
632e8b |
<samp>`hello'</samp> word is not a verb; but an expression, a kind of
|
|
|
632e8b |
greeting, an interjection specifically. In contrast, <samp>`greet'</samp> is a
|
|
|
632e8b |
verb and describes what we do when we say <samp>`Hello!'</samp>, <samp>`Hi!'</samp>,
|
|
|
632e8b |
and similar expressions.
|
|
|
632e8b |
|
|
|
632e8b |
So far, we've gathered the following function information:
|
|
|
632e8b |
|
|
|
632e8b |
Name: greet
|
|
|
632e8b |
Path: trunk/Scripts/Bash/Functions/Greet
|
|
|
632e8b |
File: trunk/Scripts/Bash/Functions/Greet/greet.sh
|
|
|
632e8b |
|
|
|
632e8b |
The <tt>`greet.sh'</tt> function script is the first file
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script loads when the <samp>`greet'</samp> functionality
|
|
|
632e8b |
is called using commands like <samp>`centos-art greet --hello='World''</samp>.
|
|
|
632e8b |
The <tt>`greet.sh'</tt> function script contains the greet function
|
|
|
632e8b |
definition.
|
|
|
632e8b |
|
|
|
632e8b |
Inside <tt>`centos-art.sh'</tt> script, as convenction, each function
|
|
|
632e8b |
script has one top commentary, followed by one blank line, and then
|
|
|
632e8b |
one function defintion below it only.
|
|
|
632e8b |
|
|
|
632e8b |
Inside <tt>`centos-art.sh'</tt> script functions, top commentaries have
|
|
|
632e8b |
the following components: the functionality description, one-line for
|
|
|
632e8b |
copyright note with your personal information, the license under
|
|
|
632e8b |
which the function source code is released --the <tt>`centos-art.sh'</tt>
|
|
|
632e8b |
script is released as GPL, so do all its functions--, the $Id$
|
|
|
632e8b |
keyword of Subversion is later expanded by svn propset
|
|
|
632e8b |
command.
|
|
|
632e8b |
|
|
|
632e8b |
In our greet function example, top commentary for
|
|
|
632e8b |
<tt>`greet.sh'</tt> function script would look like the following:
|
|
|
632e8b |
|
|
|
632e8b |
#!/bin/bash
|
|
|
632e8b |
#
|
|
|
632e8b |
# greet.sh -- This function outputs different kind of greetings to
|
|
|
632e8b |
# your screen. Use this function to understand how centos-art.sh
|
|
|
632e8b |
# script specific functionalities work.
|
|
|
632e8b |
#
|
|
|
632e8b |
# Copyright (C) YEAR YOURFULLNAME
|
|
|
632e8b |
#
|
|
|
632e8b |
# This program is free software; you can redistribute it and/or modify
|
|
|
632e8b |
# it under the terms of the GNU General Public License as published by
|
|
|
632e8b |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
632e8b |
# (at your option) any later version.
|
|
|
632e8b |
#
|
|
|
632e8b |
# This program is distributed in the hope that it will be useful, but
|
|
|
632e8b |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
632e8b |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
632e8b |
# General Public License for more details.
|
|
|
632e8b |
#
|
|
|
632e8b |
# You should have received a copy of the GNU General Public License
|
|
|
632e8b |
# along with this program; if not, write to the Free Software
|
|
|
632e8b |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
632e8b |
# USA.
|
|
|
632e8b |
#
|
|
|
632e8b |
# ----------------------------------------------------------------------
|
|
|
632e8b |
# $Id$
|
|
|
632e8b |
# ----------------------------------------------------------------------
|
|
|
632e8b |
|
|
|
632e8b |
After top commentary, separated by one blank line, the greet
|
|
|
632e8b |
function definition would look like the following:
|
|
|
632e8b |
|
|
|
632e8b |
function greet {
|
|
|
632e8b |
|
|
|
632e8b |
# Define global variables.
|
|
|
632e8b |
|
|
|
632e8b |
# Define command-line interface.
|
|
|
632e8b |
greet_getActions
|
|
|
632e8b |
|
|
|
632e8b |
}
|
|
|
632e8b |
|
|
|
632e8b |
The first definition inside greet function, are global
|
|
|
632e8b |
variables that will be available along greet function execution
|
|
|
632e8b |
environment. This time we didn't use global variable definitions for
|
|
|
632e8b |
greet function execution environment, so we left that section
|
|
|
632e8b |
empty.
|
|
|
632e8b |
|
|
|
632e8b |
Later, we call greet_getActions function to define the
|
|
|
632e8b |
command-line interface of greet functionality. The command-line
|
|
|
632e8b |
interface of greet functionality defines what and how actions
|
|
|
632e8b |
are performed, based on arguments combination passed to
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
function greet_getActions {
|
|
|
632e8b |
|
|
|
632e8b |
case "$ACTIONNAM" in
|
|
|
632e8b |
|
|
|
632e8b |
--hello )
|
|
|
632e8b |
greet_doHello
|
|
|
632e8b |
;;
|
|
|
632e8b |
|
|
|
632e8b |
--bye )
|
|
|
632e8b |
greet_doBye
|
|
|
632e8b |
;;
|
|
|
632e8b |
|
|
|
632e8b |
* )
|
|
|
632e8b |
cli_printMessage "`gettext "The option provided is not valid."`"
|
|
|
632e8b |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
632e8b |
|
|
|
632e8b |
esac
|
|
|
632e8b |
|
|
|
632e8b |
}
|
|
|
632e8b |
|
|
|
632e8b |
The ACTIONNAM global variable is defined in <tt>`cli.sh'</tt>
|
|
|
632e8b |
function script and contains the value passed before the equal sign
|
|
|
632e8b |
(i.e., <samp>`='</samp>) in the second command-line argument of
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script. For example, if the second command-line
|
|
|
632e8b |
argument is <samp>`--hello='World''</samp>, the value of ACTIONNAM
|
|
|
632e8b |
variable would be <samp>`--hello'</samp>. Using this configuration let us
|
|
|
632e8b |
deside which action to perform based on the action name passed to
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script as second argument.
|
|
|
632e8b |
|
|
|
632e8b |
The greet function definition makes available two valid
|
|
|
632e8b |
greetings through <samp>`--hello'</samp> and <samp>`--bye'</samp> options. If no
|
|
|
632e8b |
one of them is provided as second command-line argument, the <samp>`*'</samp>
|
|
|
632e8b |
case is evaluated instead.
|
|
|
632e8b |
|
|
|
632e8b |
The <samp>`*'</samp> case and its two lines further on should always be
|
|
|
632e8b |
present in <tt>`_getActions.sh'</tt> function scripts, no matter what
|
|
|
632e8b |
specific functionality you are creating. This convenction helps the
|
|
|
632e8b |
user to find out documentation about current functionality in use,
|
|
|
632e8b |
when no valid action is provided.
|
|
|
632e8b |
|
|
|
632e8b |
The greet_doHello and greet_doBye function definitions
|
|
|
632e8b |
are the core of greet specific functionality. In such function
|
|
|
632e8b |
definitions we set what our greet function really does: to
|
|
|
632e8b |
output different kinds of greetings.
|
|
|
632e8b |
|
|
|
632e8b |
function greet_doHello {
|
|
|
632e8b |
|
|
|
632e8b |
cli_printMessage "`gettext "Hello"` $ACTIONVAL"
|
|
|
632e8b |
|
|
|
632e8b |
}
|
|
|
632e8b |
|
|
|
632e8b |
The greet_doHello function definition is stored in
|
|
|
632e8b |
<tt>`greet_doHello.sh'</tt> function script.
|
|
|
632e8b |
|
|
|
632e8b |
function greet_doBye {
|
|
|
632e8b |
|
|
|
632e8b |
cli_printMessage "`gettext "Goodbye"` $ACTIONVAL"
|
|
|
632e8b |
|
|
|
632e8b |
}
|
|
|
632e8b |
|
|
|
632e8b |
The greet_doBye function definition is stored in the
|
|
|
632e8b |
<tt>`greet_doBye.sh'</tt> function script.
|
|
|
632e8b |
|
|
|
632e8b |
Both <tt>`greet_doHello.sh'</tt> and <tt>`greet_doBye.sh'</tt> function
|
|
|
632e8b |
scripts are stored inside greet function directory path (i.e.
|
|
|
632e8b |
<tt>`trunk/Scripts/Bash/Functions/Greet'</tt>).
|
|
|
632e8b |
|
|
|
632e8b |
The ACTIONVAL global variable is defined in <tt>`cli.sh'</tt>
|
|
|
632e8b |
function script and contains the value passed after the equal sign
|
|
|
632e8b |
(i.e., <samp>`='</samp>) in the second command-line argument of
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script. For example, if the second command-line
|
|
|
632e8b |
argument is <samp>`--hello='World''</samp>, the value of ACTIONVAL
|
|
|
632e8b |
variable would be <samp>`World'</samp> without quotes.
|
|
|
632e8b |
|
|
|
632e8b |
Let's see how greet specific functionality files are organzied
|
|
|
632e8b |
under greet function directory. To see file organization we use
|
|
|
632e8b |
the tree command:
|
|
|
632e8b |
|
|
|
632e8b |
trunk/Scripts/Bash/Functions/Greet
|
|
|
632e8b |
|-- greet_doBye.sh
|
|
|
632e8b |
|-- greet_doHello.sh
|
|
|
632e8b |
|-- greet_getActions.sh
|
|
|
632e8b |
`-- greet.sh
|
|
|
632e8b |
|
|
|
632e8b |
To try the greet specific functionality we've just created,
|
|
|
632e8b |
pass the function name (i.e., <samp>`greet'</samp>) as first argument to
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script, and any of the valid options as second
|
|
|
632e8b |
argument. Some examples are illustrated below:
|
|
|
632e8b |
|
|
|
632e8b |
[centos@projects ~]$ centos-art greet --hello='World'
|
|
|
632e8b |
Hello World
|
|
|
632e8b |
[centos@projects ~]$ centos-art greet --bye='World'
|
|
|
632e8b |
Goodbye World
|
|
|
632e8b |
[centos@projects ~]$
|
|
|
632e8b |
|
|
|
632e8b |
The word <samp>`World'</samp> in the examples above can be anything. In fact,
|
|
|
632e8b |
change it to have a little fun.
|
|
|
632e8b |
|
|
|
632e8b |
Now that we have a specific function that works as we expect, it is
|
|
|
632e8b |
time to document it. To document greet specific functionality,
|
|
|
632e8b |
we use its directory path and the manual functionality
|
|
|
632e8b |
(-- Removed(pxref:trunk Scripts Bash Functions Manual) --) of <tt>`centos-art.sh'</tt>
|
|
|
632e8b |
script, just as the following command illustrates:
|
|
|
632e8b |
|
|
|
632e8b |
centos-art manual --edit=trunk/Scripts/Bash/Functions/Greet
|
|
|
632e8b |
|
|
|
632e8b |
To have a well documented function helps user to understand how your
|
|
|
632e8b |
function really works, and how it should be used. When no valid
|
|
|
632e8b |
action is passed to a function, the <tt>`centos-art.sh'</tt> script uses
|
|
|
632e8b |
the function documentation entry as vehicle to communicate which the
|
|
|
632e8b |
valid functions are. When no documentation entry exists for a
|
|
|
632e8b |
function, the <tt>`centos-art.sh'</tt> script informs that no
|
|
|
632e8b |
documentation entry exists for such function and requests user to
|
|
|
632e8b |
create it right at that time.
|
|
|
632e8b |
|
|
|
632e8b |
Now that we have documented our function, it is time to translate its
|
|
|
632e8b |
output messages to different languages. To translate specific
|
|
|
632e8b |
functionality output messages to different languages we use the
|
|
|
632e8b |
locale functionality (-- Removed(pxref:trunk Scripts Bash Functions
|
|
|
632e8b |
Locale) --) of <tt>`centos-art.sh'</tt> script, just as the following command
|
|
|
632e8b |
illustrates:
|
|
|
632e8b |
|
|
|
632e8b |
centos-art locale --edit
|
|
|
632e8b |
|
|
|
632e8b |
Warning To translate output messages in different languages,
|
|
|
632e8b |
your system locale information --as in LANG environment
|
|
|
632e8b |
variable-- must be set to that locale you want to produce translated
|
|
|
632e8b |
messages for. For example, if you want to produce translated messages
|
|
|
632e8b |
for Spanish language, your system locale information must be set to
|
|
|
632e8b |
<samp>`es_ES.UTF-8'</samp>, or similar, first.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Well, it seems that our example is rather complete by now.
|
|
|
632e8b |
|
|
|
632e8b |
In greet function example we've described so far, we only use
|
|
|
632e8b |
cli_printMessage global function in action specific function
|
|
|
632e8b |
definitions in order to print messages, but more interesting things
|
|
|
632e8b |
can be achieved inside action specific function definitions. For
|
|
|
632e8b |
example, if you pass a directory path as action value in second
|
|
|
632e8b |
argument, you could retrive a list of files from therein, and process
|
|
|
632e8b |
them. If the list of files turns too long or you just want to control
|
|
|
632e8b |
which files to process, you could add the third argument in the form
|
|
|
632e8b |
<samp>`--filter='regex''</samp> and reduce the amount of files to process
|
|
|
632e8b |
using a regular expression pattern.
|
|
|
632e8b |
|
|
|
632e8b |
The greet function described in this section may serve you as
|
|
|
632e8b |
an introduction to understand how specific functionalities work inside
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script. With some of luck this introduction will
|
|
|
632e8b |
also serve you as motivation to create your own <tt>`centos-art.sh'</tt>
|
|
|
632e8b |
script specific functionalities.
|
|
|
632e8b |
|
|
|
632e8b |
By the way, the greet functionality doesn't exist inside
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script yet. Would you like to create it?
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
2.62.3 Usage
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
2.62.3.1 Global variables
|
|
|
632e8b |
|
|
|
632e8b |
The following global variables of <tt>`centos-art.sh'</tt> script, are
|
|
|
632e8b |
available for you to use inside specific functions:
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> TEXTDOMAIN
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Default domain used to retrieve translated messages. This value is set
|
|
|
632e8b |
in <tt>`initFunctions.sh'</tt> and shouldn't be changed.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> TEXTDOMAINDIR
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Default directory used to retrieve translated messages. This value is
|
|
|
632e8b |
set in <tt>`initFunctions.sh'</tt> and shouldn't be changed.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> FUNCNAM
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Define function name.
|
|
|
632e8b |
|
|
|
632e8b |
Function names associate sets of actions. There is one set of actions
|
|
|
632e8b |
for each unique function name inside <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
Dunction names are passed as first argument in <tt>`centos-art.sh'</tt>
|
|
|
632e8b |
command-line interface. For example, in the command <samp>`centos-art
|
|
|
632e8b |
render --entry=path/to/dir --filter=regex'</samp>, the ACTION passed to
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script is <samp>`render'</samp>.
|
|
|
632e8b |
|
|
|
632e8b |
When first argument is not provided, the <tt>`centos-art.sh'</tt> script
|
|
|
632e8b |
immediatly ends its execution.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> FUNCDIR
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> FUNCDIRNAME
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> FUNCSCRIPT
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> FUNCCONFIG
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> ACTIONNAM
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Define action name.
|
|
|
632e8b |
|
|
|
632e8b |
Each action name identifies an specific action to perform, inside an
|
|
|
632e8b |
specific function.
|
|
|
632e8b |
|
|
|
632e8b |
Action name names aare passed as second argument in
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> command-line interface. For example, in the
|
|
|
632e8b |
command <samp>`centos-art render --entry=path/to/dir --filter=regex'</samp>,
|
|
|
632e8b |
the ACTIONNAM passed to <tt>`centos-art.sh'</tt> script is
|
|
|
632e8b |
<samp>`--entry'</samp>.
|
|
|
632e8b |
|
|
|
632e8b |
When second argument is not provided, the <tt>`centos-art.sh'</tt> script
|
|
|
632e8b |
immediatly ends its execution.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> ACTIONVAL
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Define action value.
|
|
|
632e8b |
|
|
|
632e8b |
Action values are associated to just one action name. Action values
|
|
|
632e8b |
contain the working copy entry over which its associated action will be
|
|
|
632e8b |
performed in. Working copy entries can be files or directories inside
|
|
|
632e8b |
the working copy.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> REGEX
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Define regular expression used as pattern to build the list of files
|
|
|
632e8b |
to process.
|
|
|
632e8b |
|
|
|
632e8b |
By default, REGEX variable is set to .+ to match all
|
|
|
632e8b |
files.
|
|
|
632e8b |
|
|
|
632e8b |
Functions that need to build a list of files to process use the option
|
|
|
632e8b |
<samp>`--filter'</samp> to redefine REGEX variable default value, and
|
|
|
632e8b |
so, control the amount of files to process.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> ARGUMENTS
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Define optional arguments.
|
|
|
632e8b |
|
|
|
632e8b |
Optional arguments, inside <tt>`centos-art.sh'</tt> script, are considered
|
|
|
632e8b |
as all command-line arguments passed to <tt>`centos-art.sh'</tt> script,
|
|
|
632e8b |
from third argument position on. For example, in the command
|
|
|
632e8b |
<samp>`centos-art render --entry=path/to/dir --filter=regex'</samp> , the
|
|
|
632e8b |
optional arguments are from <samp>`--filter=regex'</samp> argument on.
|
|
|
632e8b |
|
|
|
632e8b |
Optional arguments are parsed using getopt command through
|
|
|
632e8b |
the following base construction:
|
|
|
632e8b |
|
|
|
632e8b |
# Define short options we want to support.
|
|
|
632e8b |
local ARGSS=""
|
|
|
632e8b |
|
|
|
632e8b |
# Define long options we want to support.
|
|
|
632e8b |
local ARGSL="filter:,to:"
|
|
|
632e8b |
|
|
|
632e8b |
# Parse arguments using getopt(1) command parser.
|
|
|
632e8b |
cli_doParseArguments
|
|
|
632e8b |
|
|
|
632e8b |
# Reset positional parameters using output from (getopt) argument
|
|
|
632e8b |
# parser.
|
|
|
632e8b |
eval set -- "$ARGUMENTS"
|
|
|
632e8b |
|
|
|
632e8b |
# Define action to take for each option passed.
|
|
|
632e8b |
while true; do
|
|
|
632e8b |
case "$1" in
|
|
|
632e8b |
--filter )
|
|
|
632e8b |
REGEX="$2"
|
|
|
632e8b |
shift 2
|
|
|
632e8b |
;;
|
|
|
632e8b |
--to )
|
|
|
632e8b |
TARGET="$2"
|
|
|
632e8b |
shift 2
|
|
|
632e8b |
;;
|
|
|
632e8b |
* )
|
|
|
632e8b |
break
|
|
|
632e8b |
esac
|
|
|
632e8b |
done
|
|
|
632e8b |
|
|
|
632e8b |
Optional arguments provide support to command options inside
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script. For instance, consider the Subversion
|
|
|
632e8b |
(svn ) command, where there are many options (e.g.,
|
|
|
632e8b |
<samp>`copy'</samp>, <samp>`delete'</samp>, <samp>`move'</samp>, etc), and inside each
|
|
|
632e8b |
option there are several modifiers (e.g., <samp>`--revision'</samp>,
|
|
|
632e8b |
<samp>`--message'</samp>, <samp>`--username'</samp>, etc.) that can be combined one
|
|
|
632e8b |
another in their short or long variants.
|
|
|
632e8b |
|
|
|
632e8b |
The ARGUMENTS variable is used to store arguments passed from
|
|
|
632e8b |
command-line for later use inside <tt>`centos-art.sh'</tt> script. Storing
|
|
|
632e8b |
arguments is specially useful when we want to run a command with some
|
|
|
632e8b |
specific options from them. Consider the following command:
|
|
|
632e8b |
|
|
|
632e8b |
centos-art path --copy=SOURCE --to=TARGET --message="The commit message goes here." --username='johndoe'
|
|
|
632e8b |
|
|
|
632e8b |
In the above command, the <samp>`--message'</samp>, and <samp>`--username'</samp>
|
|
|
632e8b |
options are specific to svn copy command. In such cases,
|
|
|
632e8b |
options are not interpreted by <tt>`centos-art.sh'</tt> script itself.
|
|
|
632e8b |
Instead, the <tt>`centos-art.sh'</tt> script uses getopt to
|
|
|
632e8b |
retrive them and store them in the ARGUMENTS variable for later
|
|
|
632e8b |
use, as described in the following command:
|
|
|
632e8b |
|
|
|
632e8b |
# Build subversion command to duplicate locations inside the
|
|
|
632e8b |
# workstation.
|
|
|
632e8b |
eval svn copy $SOURCE $TARGET --quiet $ARGUMENTS
|
|
|
632e8b |
|
|
|
632e8b |
When getopt parses ARGUMENTS, we may use short options
|
|
|
632e8b |
(e.g., <samp>`-m'</samp>) or long options (e.g., <samp>`--message'</samp>). When
|
|
|
632e8b |
we use short options, arguments are separated by one space from the
|
|
|
632e8b |
option (e.g., <samp>`-m 'This is a commit message.''</samp>). When we use
|
|
|
632e8b |
long options arguments are separated by an equal sign (<samp>`='</samp>)
|
|
|
632e8b |
(e.g., <samp>`--message='This is a commit message''</samp>).
|
|
|
632e8b |
|
|
|
632e8b |
In order for getopt to parse ARGUMENTS correctly, it
|
|
|
632e8b |
is required to provide the short and long definition of options that
|
|
|
632e8b |
will be passed or at least supported by the command performing the
|
|
|
632e8b |
final action the function script exists for.
|
|
|
632e8b |
|
|
|
632e8b |
As convenction, inside <tt>`centos-art.sh'</tt> script, short option
|
|
|
632e8b |
definitions are set in the ARGSS variable; and long option
|
|
|
632e8b |
definitions are set in the ARGSL variable.
|
|
|
632e8b |
|
|
|
632e8b |
When you define short and long options, it may be needed to define
|
|
|
632e8b |
which of these option arguments are required and which not. To define
|
|
|
632e8b |
an option argument as required, you need to set one colon <samp>`:'</samp>
|
|
|
632e8b |
after the option definition (e.g., <samp>`-o m: -l message:'</samp>). On
|
|
|
632e8b |
the other hand, to define an option argument as not required, you need
|
|
|
632e8b |
to set two colons <samp>`::'</samp> after the option definition (e.g.,
|
|
|
632e8b |
<samp>`-o m:: -l message::'</samp>).
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Variable:</u> EDITOR
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
671838 |
Default text editor.
|
|
|
063806 |
|
|
|
671838 |
The <tt>`centos-art.sh'</tt> script uses default text EDITOR to edit
|
|
|
671838 |
pre-commit subversion messages, translation files, configuration
|
|
|
671838 |
files, script files, and similar text-based files.
|
|
|
063806 |
|
|
|
671838 |
If EDITOR environment variable is not set, <tt>`centos-art.sh'</tt>
|
|
|
671838 |
script uses <tt>`/usr/bin/vim'</tt> as default text editor. Otherwise, the
|
|
|
671838 |
following values are recognized by <tt>`centos-art.sh'</tt> script:
|
|
|
063806 |
|
|
|
671838 |
|
|
|
671838 |
<tt>`/usr/bin/vim'</tt>
|
|
|
671838 |
<tt>`/usr/bin/emacs'</tt>
|
|
|
671838 |
<tt>`/usr/bin/nano'</tt>
|
|
|
671838 |
|
|
|
671838 |
|
|
|
671838 |
If no one of these values is set in EDITOR environment variable,
|
|
|
671838 |
<tt>`centos-art.sh'</tt> uses <tt>`/usr/bin/vim'</tt> text editor by default.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
2.62.3.2 Global functions
|
|
|
632e8b |
|
|
|
632e8b |
Function scripts stored directly under
|
|
|
632e8b |
<tt>`trunk/Scripts/Bash/Functions/'</tt> directory are used to define
|
|
|
632e8b |
global functions. Global functions can be used inside action specific
|
|
|
632e8b |
functionalities and or even be reused inside themselves. This section
|
|
|
632e8b |
provides introductory information to global functions you can use
|
|
|
632e8b |
inside <tt>`centos-art.sh'</tt> script.
|
|
|
063806 |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_checkActionArguments
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Validate action value (ACTIONVAL) variable.
|
|
|
063806 |
|
|
|
632e8b |
The action value variable can take one of the following values:
|
|
|
063806 |
|
|
|
632e8b |
|
|
|
632e8b |
Path to one directory inside the local working copy,
|
|
|
632e8b |
Path to one file inside the local working copy,
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
If another value different from that specified above is passed to
|
|
|
632e8b |
action value variable, the <tt>`centos-art.sh'</tt> script prints an error
|
|
|
632e8b |
message and ends script execution.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_checkFiles FILE [TYPE]
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Verify file existence.
|
|
|
632e8b |
|
|
|
632e8b |
cli_checkFiles receives a FILE absolute path and performs
|
|
|
632e8b |
file verification as specified in TYPE. When TYPE is not
|
|
|
632e8b |
specified, cli_checkFiles verifies FILE existence, no
|
|
|
632e8b |
matter what kind of file it be. If TYPE is specified, use one
|
|
|
632e8b |
of the following values:
|
|
|
063806 |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`d'</samp>
|
|
|
632e8b |
<samp>`directory'</samp>
|
|
|
632e8b |
Ends script execution if FILE is not a directory.
|
|
|
063806 |
|
|
|
632e8b |
When you verify directories with cli_checkFiles, if directory doesn't
|
|
|
632e8b |
exist, <tt>`centos-art.sh'</tt> script asks you for confirmation in order
|
|
|
632e8b |
to create that directory. If you answer positively,
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script creates that directory and continues
|
|
|
632e8b |
script flows normally. Otherwise, if you answer negatively,
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> ends script execution with an error and
|
|
|
632e8b |
documentation message.
|
|
|
063806 |
|
|
|
f66721 |
|
|
|
632e8b |
<samp>`f'</samp>
|
|
|
632e8b |
<samp>`regular-file'</samp>
|
|
|
632e8b |
Ends script execution if FILE is not a regular file.
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`h'</samp>
|
|
|
632e8b |
<samp>`symbolic-link'</samp>
|
|
|
632e8b |
Ends script execution if FILE is not a symbolic link.
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`x'</samp>
|
|
|
632e8b |
<samp>`execution'</samp>
|
|
|
632e8b |
Ends script execution if FILE is not executable.
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`fh'</samp>
|
|
|
632e8b |
Ends script execution if FILE is neither a regular file nor a
|
|
|
632e8b |
symbolic link.
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`fd'</samp>
|
|
|
632e8b |
Ends script execution if FILE is neither a regular file nor a
|
|
|
632e8b |
directory.
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`isInWorkingCopy'</samp>
|
|
|
632e8b |
Ends script execution if FILE is not inside the working copy.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
As default behaviour, if FILE passes all verifications,
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script continues with its normal flow.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_commitRepoChanges [LOCATION]
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Syncronize changes between repository and working copy.
|
|
|
632e8b |
|
|
|
632e8b |
The cli_commitRepoChanges function brings changes from the
|
|
|
632e8b |
central repository down to the working copy--using svn
|
|
|
632e8b |
update--, checks the working copy changes--using svn
|
|
|
632e8b |
status command--, prints status report--using both svn
|
|
|
632e8b |
update and svn status commands output, and finally, commits
|
|
|
632e8b |
recent changes from the working copy up to the repository--using
|
|
|
632e8b |
svn commit command--.
|
|
|
632e8b |
|
|
|
632e8b |
Previous to commit the working copy changes up to the central
|
|
|
632e8b |
repository, the cli_commitRepoChanges function asks you to
|
|
|
632e8b |
verify changes--using svn diff command--, and later,
|
|
|
632e8b |
another confirmation question is shown to be sure you really want to
|
|
|
632e8b |
commit changes up to central repository.
|
|
|
632e8b |
|
|
|
632e8b |
If LOCATION argument is not specified, the value of
|
|
|
632e8b |
ACTIONVAL variable is used as reference instead.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
--> Bringing changes from the repository into the working copy
|
|
|
632e8b |
--> Checking changes in the working copy
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
Added 0 file from the repository.
|
|
|
632e8b |
Deleted 0 file from the repository.
|
|
|
632e8b |
Updated 0 file from the repository.
|
|
|
632e8b |
Conflicted 0 file from the repository.
|
|
|
632e8b |
Merged 0 file from the repository.
|
|
|
632e8b |
Modified 4 files from the working copy.
|
|
|
632e8b |
Unversioned 0 file from the working copy.
|
|
|
632e8b |
Deleted 0 file from the working copy.
|
|
|
632e8b |
Added 0 file from the working copy.
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
|
|
|
632e8b |
Figure 2.3: The cli_commitRepoChanges function output.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Call the cli_commitRepoChanges function before or/and after
|
|
|
632e8b |
calling functions that modify files or directories inside the working
|
|
|
632e8b |
copy as you may need to.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_doParseArguments
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Redefine arguments (ARGUMENTS) global variable using
|
|
|
632e8b |
getopt command output. For more information about how to use
|
|
|
632e8b |
cli_doParseArguments function, see ARGUMENTS variable
|
|
|
632e8b |
description above.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_doParseArgumentsReDef $@
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Initialize/reset arguments (ARGUMENTS) global variable using
|
|
|
632e8b |
positional parameters variable ($@) as reference.
|
|
|
632e8b |
|
|
|
632e8b |
When we work inside function definitions, positional parameters are
|
|
|
632e8b |
reset to the last function definition positional parameters. If you
|
|
|
632e8b |
need to redefine positional parameters from one specific function, you
|
|
|
632e8b |
need to call cli_doParseArgumentsReDef with the positional
|
|
|
632e8b |
parameters variable ($@), set as first argument, to that
|
|
|
632e8b |
specific function you want to redefine positional parameters at.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getArguments
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Initialize function name (FUNCNAM), action name
|
|
|
632e8b |
(ACTIONNAM), and action value (ACTIONVAL) global
|
|
|
632e8b |
variables, using positional parameters passed in $@ variable.
|
|
|
632e8b |
|
|
|
632e8b |
The cli_getArguments function is called from cli.sh
|
|
|
632e8b |
function script, using cli function positional parameters
|
|
|
632e8b |
(i.e., the positional parameters passed as arguments in the
|
|
|
632e8b |
command-line) as first function argument.
|
|
|
632e8b |
|
|
|
632e8b |
Once command-line positional parameters are accesible to
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script execution evironment,
|
|
|
632e8b |
cli_getArguments uses regular expression to retrive
|
|
|
632e8b |
action variables from first and second argument. The first argument
|
|
|
632e8b |
defines the value used as function name (FUNCNAM), and the
|
|
|
632e8b |
second argument defines both values used as action name
|
|
|
632e8b |
(ACTIONNAM) and action value (ACTIONVAL), respectively.
|
|
|
632e8b |
|
|
|
632e8b |
The first argument is a word in lower case. This word specifies the
|
|
|
632e8b |
name of the functionality you want to use (e.g., <samp>`render'</samp> to
|
|
|
632e8b |
render images, <samp>`manual'</samp> to work on documentation, and so on.)
|
|
|
632e8b |
|
|
|
632e8b |
The second argument has a long option style (e.g.,
|
|
|
632e8b |
<samp>`--option=value'</samp>). The <samp>`--option'</samp> represents the action name
|
|
|
632e8b |
(ACTIONNAM), and the characters inbetween the equal sign
|
|
|
632e8b |
(<samp>`='</samp>) and the first space character, are considered as the action
|
|
|
632e8b |
value (ACTIONVAL). In order to provide action values with space
|
|
|
632e8b |
characters inbetween you need to enclose action value with quotes like
|
|
|
632e8b |
in <samp>`--option='This is long value with spaces inbetween''</samp>.
|
|
|
632e8b |
Generally, action values are used to specify paths over which the
|
|
|
632e8b |
action name acts on.
|
|
|
632e8b |
|
|
|
632e8b |
Once action related variables (i.e., FUNCNAM, ACTIONNAM,
|
|
|
632e8b |
and ACTIONVAL) are defined and validated,
|
|
|
632e8b |
cli_getArguments shifts the positional arguments to remove the
|
|
|
632e8b |
first two arguments passed (i.e., those used to retrive action related
|
|
|
632e8b |
variables) and redefine the arguments (ARGUMENTS) global
|
|
|
632e8b |
variable with the new positional parameters information.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getFunctions
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Initialize funtionalities supported by <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
Functionalities supported by <tt>`centos-art.sh'</tt> script are organized
|
|
|
632e8b |
in functionality directories under
|
|
|
632e8b |
<tt>`trunk/Scripts/Bash/Functions/'</tt> directory. Each functionality
|
|
|
632e8b |
directory stores function scripts to the functionality such directory
|
|
|
632e8b |
was created for. Function scripts contain function definitions.
|
|
|
632e8b |
Function definitions contain several commands focused on achieving one
|
|
|
632e8b |
specific task only (i.e., the one such functionality was created for).
|
|
|
632e8b |
|
|
|
632e8b |
In order for <tt>`centos-art.sh'</tt> script to recognize a functionality,
|
|
|
632e8b |
such functionality needs to be stored under
|
|
|
632e8b |
<tt>`trunk/Scripts/Bash/Functions/'</tt> in a directory written
|
|
|
632e8b |
capitalized (i.e., the whole name is written in lowercase except the
|
|
|
632e8b |
first character which is in uppercase). The directory where one
|
|
|
632e8b |
specific functionality is stored is known as the <samp>`functionality
|
|
|
632e8b |
directory'</samp>.
|
|
|
632e8b |
|
|
|
632e8b |
Inside each functionality directory, the functionalty itself is
|
|
|
632e8b |
implemented through function scripts. Function scripts are organized
|
|
|
632e8b |
in files independently one another and written in <samp>`camelCase'</samp>
|
|
|
632e8b |
format with the function name as prefix. Separation between prefix
|
|
|
632e8b |
and description is done using underscore (<samp>`_'</samp>) character.
|
|
|
632e8b |
|
|
|
632e8b |
In order for <tt>`centos-art.sh'</tt> script to load functionalities
|
|
|
632e8b |
correctly, function definition inside function scripts should be set
|
|
|
632e8b |
using the <samp>`function'</samp> reserved word, just as in the following
|
|
|
632e8b |
example:
|
|
|
632e8b |
|
|
|
632e8b |
function prefix_doSomething {
|
|
|
632e8b |
|
|
|
632e8b |
# Do something here...
|
|
|
632e8b |
|
|
|
632e8b |
}
|
|
|
632e8b |
|
|
|
632e8b |
The above function definition is just a convenction we use, in order
|
|
|
632e8b |
to make identification of function names easier read and automate by
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script initialization commands, once
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script determines which functionality directory
|
|
|
632e8b |
to use. Specifically, in order to initialize and export functions,
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script executes all function scripts inside the
|
|
|
632e8b |
functionality directory, and later grep on them using a
|
|
|
632e8b |
regular expression pattern, where the <samp>`function'</samp> reserved word is
|
|
|
632e8b |
used as reference to retrive the function names and export them to
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script execution environment, and so, make
|
|
|
632e8b |
function definitions --from function scripts inside the functionality
|
|
|
632e8b |
directory-- available for further calls.
|
|
|
632e8b |
|
|
|
632e8b |
If the functionality specified in the command-line first argument
|
|
|
632e8b |
doesn't have a functionality directory, <tt>`centos-art.sh'</tt> script
|
|
|
632e8b |
considers the functionality provided in the command-line as invalid
|
|
|
632e8b |
functionality and immediatly stops script execution with an error
|
|
|
632e8b |
message.
|
|
|
632e8b |
|
|
|
632e8b |
In order to keep visual consistency among function scripts, please
|
|
|
632e8b |
consider using the following function script design model as template
|
|
|
632e8b |
for your own function scripts:
|
|
|
632e8b |
|
|
|
632e8b |
#!/bin/bash
|
|
|
632e8b |
#
|
|
|
632e8b |
# prefix_doSomething.sh -- This function illustrates function scripts
|
|
|
632e8b |
# design model you can use to create your own function scripts inside
|
|
|
632e8b |
# centos-art.sh script.
|
|
|
632e8b |
#
|
|
|
632e8b |
# Copyright (C) YEAR YOURFULLNAME
|
|
|
632e8b |
#
|
|
|
632e8b |
# This program is free software; you can redistribute it and/or modify
|
|
|
632e8b |
# it under the terms of the GNU General Public License as published by
|
|
|
632e8b |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
632e8b |
# (at your option) any later version.
|
|
|
632e8b |
#
|
|
|
632e8b |
# This program is distributed in the hope that it will be useful, but
|
|
|
632e8b |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
632e8b |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
632e8b |
# General Public License for more details.
|
|
|
632e8b |
#
|
|
|
632e8b |
# You should have received a copy of the GNU General Public License
|
|
|
632e8b |
# along with this program; if not, write to the Free Software
|
|
|
632e8b |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
632e8b |
# USA.
|
|
|
632e8b |
#
|
|
|
632e8b |
# ----------------------------------------------------------------------
|
|
|
632e8b |
# $Id$
|
|
|
632e8b |
# ----------------------------------------------------------------------
|
|
|
632e8b |
|
|
|
632e8b |
function prefix_doSomething {
|
|
|
632e8b |
|
|
|
632e8b |
# Do something here...
|
|
|
632e8b |
|
|
|
632e8b |
}
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getCountryCodes [FILTER]
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Output country codes supported by <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
The cli_getCountryCodes function outputs a list with country
|
|
|
632e8b |
codes as defined in ISO3166 standard. When FILTER is provided,
|
|
|
632e8b |
cli_getCountryCodes outputs country codes that match
|
|
|
632e8b |
FILTER regular expression pattern.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getCountryName [FILTER]
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Outputs country name supported by <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
The cli_getCountryName function reads one language locale code
|
|
|
632e8b |
in the format LL_CC and outputs the name of its related country as in
|
|
|
632e8b |
ISO3166. If filter is specified, cli_getCountryName returns the
|
|
|
632e8b |
country name that matches the locale code specified in FILTER,
|
|
|
632e8b |
exactly.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getCurrentLocale
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Output current locale used by <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
The cli_getCurrentLocale function uses LANG environment
|
|
|
632e8b |
variable to build a locale pattern that is later applied to
|
|
|
632e8b |
cli_getLocales function output in order to return the current
|
|
|
632e8b |
locale that <tt>`centos-art.sh'</tt> script works with.
|
|
|
632e8b |
|
|
|
632e8b |
The current locale information, returned by
|
|
|
632e8b |
cli_getCurrentLocale , is output from more specific to less
|
|
|
632e8b |
specific. For example, if <samp>`en_GB'</samp> locale exists in
|
|
|
632e8b |
cli_getLocales function output, the <samp>`en_GB'</samp> locale would
|
|
|
632e8b |
take precedence before <samp>`en'</samp> locale.
|
|
|
632e8b |
|
|
|
632e8b |
Locale precedence selection is quite important in order to define the
|
|
|
632e8b |
locale type we use for message translations. For example, if
|
|
|
632e8b |
<samp>`en_GB'</samp> is used, we are also saying that the common language
|
|
|
632e8b |
specification for English language (i.e., <samp>`en'</samp>) is no longer
|
|
|
632e8b |
used. Instead, we are using English non-common country-specific
|
|
|
632e8b |
language specifications like <samp>`en_AU'</samp>, <samp>`en_BW'</samp>, <samp>`en_GB'</samp>,
|
|
|
632e8b |
<samp>`en_US'</samp>, etc., for message translations.
|
|
|
632e8b |
|
|
|
632e8b |
Use cli_getCurrentLocale function to know what current locale
|
|
|
632e8b |
information to use inside <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getFilesList [LOCATION]
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Output list of files to process.
|
|
|
632e8b |
|
|
|
632e8b |
The cli_getFilesList function uses LOCATION variable as
|
|
|
632e8b |
source location to build a list of files just as specified by regular
|
|
|
632e8b |
expression (REGEX) global variable. Essentially, what the
|
|
|
632e8b |
cli_getFilesList function does is using find command
|
|
|
632e8b |
to look for files in the location (LOCATION) just as posix-egrep
|
|
|
632e8b |
regular expression (REGEX) specifies.
|
|
|
632e8b |
|
|
|
632e8b |
If LOCATION is not specified when cli_getFilesList
|
|
|
632e8b |
function is called, the action value (ACTIONVAL) global variable
|
|
|
632e8b |
is used as location value instead.
|
|
|
632e8b |
|
|
|
632e8b |
By default, if the regular expression (REGEX) global variable is
|
|
|
632e8b |
not redefined after its first definition in the cli function,
|
|
|
632e8b |
all files that match default regular expression value (i.e.,
|
|
|
632e8b |
<samp>`.+'</samp>) will be added to the list of files to process. Otherwise,
|
|
|
632e8b |
if you redefine the regular expression global variable after its first
|
|
|
632e8b |
definition in the cli function and before calling
|
|
|
632e8b |
cli_getFilesList function, the last value you specifed is used
|
|
|
632e8b |
instead.
|
|
|
632e8b |
|
|
|
632e8b |
When you need to customize the regular expression (REGEX) global
|
|
|
632e8b |
variable value inside a function, do not redefine the global variable
|
|
|
632e8b |
(at least you be absolutly convinced you need to). Instead, set the
|
|
|
632e8b |
regular expression global variable as <samp>`local'</samp> to the function you
|
|
|
632e8b |
need a customized regular expression value for. If we don't redefine
|
|
|
632e8b |
the regular expression global variable as local to the function, or
|
|
|
632e8b |
use another name for the regular expression variable (which is not
|
|
|
632e8b |
very convenient in order to keep the amount of names to remember low),
|
|
|
632e8b |
you may experiment undesired concantenation issues that make your
|
|
|
632e8b |
regular expression to be something different from that you expect them
|
|
|
632e8b |
to be, specially if the function where you are doing the variable
|
|
|
632e8b |
redefinition is called several times during the same script execution.
|
|
|
632e8b |
|
|
|
632e8b |
As result, the cli_getFilesList re-defines the value of
|
|
|
632e8b |
FILES variable with the list of files the find command
|
|
|
632e8b |
returned. As example, consider the following construction:
|
|
|
632e8b |
|
|
|
632e8b |
function prefix_doSomething {
|
|
|
632e8b |
|
|
|
632e8b |
# Initialize the list of files to process.
|
|
|
632e8b |
local FILES=''
|
|
|
632e8b |
|
|
|
632e8b |
# Initialize location.
|
|
|
632e8b |
local LOCATION=/home/centos/artwork/trunk/Identity/Themes/Models/Default
|
|
|
632e8b |
|
|
|
632e8b |
# Re-define regular expression to match scalable vector graphic
|
|
|
632e8b |
# files only. Note how we use the global value of REGEX to build a
|
|
|
632e8b |
# new local REGEX value here.
|
|
|
632e8b |
local REGEX="${REGEX}.*\.(svgz|svg)"
|
|
|
632e8b |
|
|
|
632e8b |
# Redefine list of files to process.
|
|
|
632e8b |
cli_getFilesList $LOCATION
|
|
|
632e8b |
|
|
|
632e8b |
# Process list of files.
|
|
|
632e8b |
for FILE in $FILES;do
|
|
|
632e8b |
cli_printMessages "$FILE" 'AsResponseLine'
|
|
|
632e8b |
# Do something else here on...
|
|
|
632e8b |
done
|
|
|
632e8b |
|
|
|
632e8b |
}
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getLangCodes [FILTER]
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Outputs language codes supported by <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
cli_getLangCodes function outputs a list of language codes as
|
|
|
632e8b |
defined in ISO639 standard. When FILTER is provided,
|
|
|
632e8b |
cli_getLangCodes outputs language codes that match FILTER
|
|
|
632e8b |
regular expression pattern.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getLangName [FILTER]
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Outputs language names supported by <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
cli_getLangName function reads one language locale code in the
|
|
|
632e8b |
format LL_CC and outputs the language related name as in ISO639. If
|
|
|
632e8b |
filter is specified, cli_getLangName returns the language name
|
|
|
632e8b |
that matches the locale code specified in FILTER, exactly.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getLocales
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Output locale codes supported by <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
Occasionally, you use cli_getLocales function to add locale
|
|
|
632e8b |
information in non-common country-specific language (<samp>`LL_CC'</samp>)
|
|
|
632e8b |
format for those languages (e.g., <samp>`bn_IN'</samp>, <samp>`pt_BR'</samp>, etc.)
|
|
|
632e8b |
which locale differences cannot be solved using common language
|
|
|
632e8b |
specifications (<samp>`LL'</samp>) into one unique common locale specification
|
|
|
632e8b |
(e.g., <samp>`bn'</samp>, <samp>`pt'</samp>, etc.).
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getRepoName NAME TYPE
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Sanitate file names.
|
|
|
632e8b |
|
|
|
632e8b |
Inside <tt>`centos-art.sh'</tt> script, specific functionalities rely both
|
|
|
632e8b |
in cli_getRepoName and repository file system organization to
|
|
|
632e8b |
achieve their goals. Consider cli_getRepoName function as
|
|
|
632e8b |
central place to manage file name convenctions for other functions
|
|
|
632e8b |
inside <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
Important cli_getRepoName function doesn't verify file
|
|
|
632e8b |
or directory existence, for that purpose use cli_checkFiles
|
|
|
632e8b |
function instead.
|
|
|
671838 |
|
|
|
671838 |
|
|
|
632e8b |
The NAME variable contains the file name or directory name you
|
|
|
632e8b |
want to sanitate.
|
|
|
063806 |
|
|
|
632e8b |
The TYPE variable specifies what type of sanitation you want to
|
|
|
632e8b |
perform on NAME. The TYPE can be one of the following
|
|
|
632e8b |
values:
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`d'</samp>
|
|
|
632e8b |
<samp>`directory'</samp>
|
|
|
632e8b |
Sanitate directory NAMEs.
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`f'</samp>
|
|
|
632e8b |
<samp>`regular-file'</samp>
|
|
|
632e8b |
Sanitate regular file NAMEs.
|
|
|
632e8b |
|
|
|
063806 |
|
|
|
063806 |
|
|
|
632e8b |
Use cli_getRepoName function to sanitate file names and
|
|
|
632e8b |
directory names before their utilization.
|
|
|
632e8b |
|
|
|
632e8b |
Use cli_getRepoName when you need to change file name
|
|
|
632e8b |
convenctions inside <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
When we change file name convenctions inside cli_getRepoName
|
|
|
632e8b |
what we are really changing is the way functions interpret repository
|
|
|
632e8b |
file system organization. Notice that when we change a file name
|
|
|
632e8b |
(e.g., a function name), it is necessary to update all files where
|
|
|
632e8b |
such file name is placed on. This may require a massive substitution
|
|
|
632e8b |
inside the repository, each time we change name convenctions in the
|
|
|
632e8b |
repository (-- Removed(pxref:trunk Scripts Bash Functions Path) --, for more
|
|
|
632e8b |
information).
|
|
|
632e8b |
|
|
|
063806 |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getRepoStatus [LOCATION]
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Request repository status.
|
|
|
632e8b |
|
|
|
632e8b |
This function requests the status of a LOCATION inside the
|
|
|
632e8b |
working copy using the svn status command and returns the
|
|
|
632e8b |
first character in the output line, just as described in svn
|
|
|
632e8b |
help status. If LOCATION is not a regular file or a directory,
|
|
|
632e8b |
inside the working copy, the <tt>`centos-art.sh'</tt> script prints a
|
|
|
632e8b |
message and ends its execution.
|
|
|
632e8b |
|
|
|
632e8b |
Use this function to perform verifications based a repository
|
|
|
632e8b |
LOCATION status.
|
|
|
632e8b |
|
|
|
f66721 |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getTemporalFile NAME
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Output absolute path to temporal file NAME.
|
|
|
632e8b |
|
|
|
632e8b |
The cli_getTemporalFile function uses <tt>`/tmp'</tt> directory as
|
|
|
632e8b |
source location to store temporal files, the <tt>`centos-art.sh'</tt>
|
|
|
632e8b |
script name, and a random identification string to let you run more
|
|
|
632e8b |
than one <tt>`centos-art.sh'</tt> script simultaneously on the same user
|
|
|
632e8b |
session. For example, due the following temporal file defintion:
|
|
|
632e8b |
|
|
|
632e8b |
cli_getTemporalFile $FILE
|
|
|
632e8b |
|
|
|
632e8b |
If FILE name is <tt>`instance.svg'</tt> and the unique random string
|
|
|
632e8b |
is <samp>`f16f7b51-ac12-4b7f-9e66-72df847f12de'</samp>, the final temporal
|
|
|
632e8b |
file, built from previous temporal file definition, would be:
|
|
|
632e8b |
|
|
|
632e8b |
/tmp/centos-art.sh-f16f7b51-ac12-4b7f-9e66-72df847f12de-instance.svg
|
|
|
632e8b |
|
|
|
632e8b |
When you use the cli_getTemporalFile function to create
|
|
|
632e8b |
temporal files, be sure to remove temporal files created once you've
|
|
|
632e8b |
ended up with them. For example, consider the following construction:
|
|
|
632e8b |
|
|
|
632e8b |
for FILE in $FILES;do
|
|
|
632e8b |
|
|
|
632e8b |
# Initialize temporal instance of file.
|
|
|
632e8b |
INSTANCE=$(cli_getTemporalFile $FILE)
|
|
|
632e8b |
|
|
|
632e8b |
# Do something ...
|
|
|
632e8b |
|
|
|
632e8b |
# Remove temporal instance of file.
|
|
|
632e8b |
if [[ -f $INSTANCE ]];then
|
|
|
632e8b |
rm $INSTANCE
|
|
|
632e8b |
fi
|
|
|
632e8b |
|
|
|
632e8b |
done
|
|
|
632e8b |
|
|
|
632e8b |
Use the cli_getTemporalFile function whenever you need to
|
|
|
632e8b |
create temporal files inside <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_getThemeName
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Output theme name.
|
|
|
632e8b |
|
|
|
632e8b |
In order for cli_getThemeName function to extract theme name
|
|
|
632e8b |
correctly, the ACTIONVAL variable must contain a directory path
|
|
|
632e8b |
under <tt>`trunk/Identity/Themes/Motifs/'</tt> directory structure.
|
|
|
632e8b |
Otherwise, cli_getThemeName returns an empty string.
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<u>Function:</u> cli_printMessage MESSAGE [FORMAT]
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
Define standard output message definition supported by
|
|
|
632e8b |
<tt>`centos-art.sh'</tt> script.
|
|
|
671838 |
|
|
|
632e8b |
When FORMAT is not specified, cli_printMessage outputs
|
|
|
632e8b |
information just as it was passed in MESSAGE variable.
|
|
|
632e8b |
Otherwise, FORMAT can take one of the following values:
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsHeadingLine'</samp>
|
|
|
632e8b |
To print heading messages.
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
$MESSAGE
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsWarningLine'</samp>
|
|
|
632e8b |
To print warning messages.
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
WARNING: $MESSAGE
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsNoteLine'</samp>
|
|
|
632e8b |
To print note messages.
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
NOTE: $MESSAGE
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsUpdatingLine'</samp>
|
|
|
632e8b |
To print <samp>`Updating'</samp> messages on two-columns format.
|
|
|
632e8b |
Updating $MESSAGE
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsRemovingLine'</samp>
|
|
|
632e8b |
To print <samp>`Removing'</samp> messages on two-columns format.
|
|
|
632e8b |
Removing $MESSAGE
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsCheckingLine'</samp>
|
|
|
632e8b |
To print <samp>`Checking'</samp> messages on two-columns format.
|
|
|
632e8b |
Checking $MESSAGE
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsCreatingLine'</samp>
|
|
|
632e8b |
To print <samp>`Creating'</samp> messages on two-columns format.
|
|
|
632e8b |
Creating $MESSAGE
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsSavedAsLine'</samp>
|
|
|
632e8b |
To print <samp>`Saved as'</samp> messages on two-columns format.
|
|
|
632e8b |
Saved as $MESSAGE
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsLinkToLine'</samp>
|
|
|
632e8b |
To print <samp>`Linked to'</samp> messages on two-columns format.
|
|
|
632e8b |
Linked to $MESSAGE
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsMovedToLine'</samp>
|
|
|
632e8b |
To print <samp>`Moved to'</samp> messages on two-columns format.
|
|
|
632e8b |
Moved to $MESSAGE
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsTranslationLine'</samp>
|
|
|
632e8b |
To print <samp>`Translation'</samp> messages on two-columns format.
|
|
|
632e8b |
Translation $MESSAGE
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsConfigurationLine'</samp>
|
|
|
632e8b |
To print <samp>`Configuration'</samp> messages on two-columns format.
|
|
|
632e8b |
Configuration $MESSAGE
|
|
|
632e8b |
|
|
|
671838 |
|
|
|
632e8b |
<samp>`AsResponseLine'</samp>
|
|
|
632e8b |
To print response messages on one-column format.
|
|
|
632e8b |
--> $MESSAGE
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsRequestLine'</samp>
|
|
|
632e8b |
To print request messages on one-column format. Request messages
|
|
|
632e8b |
output messages with one colon (<samp>`:'</samp>) and without trailing newline
|
|
|
632e8b |
(<samp>`\n'</samp>) at message end.
|
|
|
632e8b |
$MESSAGE:
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
<samp>`AsYesOrNoRequestLine'</samp>
|
|
|
632e8b |
To print <samp>`yes or no'</samp> request messages on one-column format. If
|
|
|
632e8b |
something different from <samp>`y'</samp> is answered (when using
|
|
|
632e8b |
en_US.UTF-8 locale), script execution ends immediatly.
|
|
|
632e8b |
|
|
|
632e8b |
$MESSAGE [y/N]:
|
|
|
632e8b |
|
|
|
632e8b |
When we use <tt>`centos-art.sh'</tt> script in a locale different from
|
|
|
632e8b |
en_US.UTF-8 , confirmation answer may be different from
|
|
|
632e8b |
<samp>`y'</samp>. For example, if you use es_ES.UTF-8 locale, the
|
|
|
632e8b |
confirmation question would look like:
|
|
|
632e8b |
|
|
|
632e8b |
$MESSAGE [s/N]:
|
|
|
632e8b |
|
|
|
632e8b |
and the confirmation answer would be <samp>`s'</samp>, as it is on Spanish
|
|
|
632e8b |
<samp>`sí'</samp> word.
|
|
|
632e8b |
|
|
|
632e8b |
Definition of which confirmation word to use is set on translation
|
|
|
632e8b |
messages for your specific locale information. -- Removed(xref:trunk Scripts
|
|
|
632e8b |
Bash Functions Locale) --, for more information about locale-specific
|
|
|
632e8b |
translation messages.
|
|
|
671838 |
|
|
|
671838 |
|
|
|
632e8b |
<samp>`AsToKnowMoreLine'</samp>
|
|
|
632e8b |
To standardize <samp>`to know more, run the following command:'</samp>
|
|
|
632e8b |
messages. When the <samp>`AsToKnowMoreLine'</samp> option is used, the
|
|
|
632e8b |
MESSAGE value should be set to "$(caller)" . caller
|
|
|
632e8b |
is a Bash builtin that returns the context of the current subroutine
|
|
|
632e8b |
call. <samp>`AsToKnowMoreLine'</samp> option uses caller builtin
|
|
|
632e8b |
output to build documentation entries dynamically.
|
|
|
632e8b |
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
To know more, run the following command:
|
|
|
632e8b |
centos-art manual --read='path/to/dir'
|
|
|
632e8b |
----------------------------------------------------------------------
|
|
|
632e8b |
|
|
|
632e8b |
Use <samp>`AsToKnowMoreLine'</samp> option after errors and for intentional
|
|
|
632e8b |
script termination.
|
|
|
063806 |
|
|
|
063806 |
|
|
|
632e8b |
<samp>`AsRegularLine'</samp>
|
|
|
632e8b |
To standardize regular messages on one-column format.
|
|
|
632e8b |
|
|
|
632e8b |
When MESSAGE contains a colon inside (e.g., <samp>`description:
|
|
|
632e8b |
message'</samp>), the cli_printMessage function outputs MESSAGE
|
|
|
632e8b |
on two-columns format.
|
|
|
632e8b |
|
|
|
063806 |
|
|
|
063806 |
|
|
|
632e8b |
Use cli_printMessage function whenever you need to output
|
|
|
632e8b |
information from <tt>`centos-art.sh'</tt> script.
|
|
|
632e8b |
|
|
|
632e8b |
Tip To improve two-columns format, change the following file:
|
|
|
632e8b |
trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
632e8b |
2.62.3.3 Specific functions
|
|
|
632e8b |
|
|
|
632e8b |
The following specific functions of <tt>`centos-art.sh'</tt> script, are
|
|
|
632e8b |
available for you to use:
|
|
|
632e8b |
|
|
|
632e8b |
|
|
|
063806 |
|
|
|
632e8b |
|
|
|
671838 |
2.62.4 See also
|
|
|
063806 |
|
|
|
063806 |
|
|
|
632e8b |
2.60 The <tt>`trunk/Scripts/Bash'</tt> Directory
|
|
|
063806 |
|
|
|
982d5c |
|
|
|
982d5c |
|
|
|
010b2d |
|
|
|
010b2d |
|
|
|
632e8b |
[ < ]
|
|
|
632e8b |
[ > ]
|
|
|
010b2d |
|
|
|
671838 |
[ << ]
|
|
|
632e8b |
[ Up ]
|
|
|
632e8b |
[ >> ]
|
|
|
010b2d |
|
|
|
010b2d |
|
|
|
010b2d |
<font size="-1">
|
|
|
632e8b |
This document was generated on March, 4 2011 using texi2html 1.76.
|
|
|
010b2d |
</font>
|
|
|
010b2d |
|
|
|
010b2d |
|
|
|
010b2d |
|
|
|
010b2d |
</body>
|
|
|
010b2d |
</html>
|