|
|
4c79b5 |
|
|
|
4c79b5 |
<html>
|
|
|
09d4f2 |
|
|
|
09d4f2 |
|
|
|
09d4f2 |
The CentOS Artwork Repository exists to organize and automate The
|
|
|
09d4f2 |
CentOS Project corporate visual identity (, to
|
|
|
09d4f2 |
start on).
|
|
|
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 |
-->
|
|
|
008ee0 |
|
|
|
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>
|
|
|
63f275 |
<title>CentOS Artwork Repository: 3.37 trunk/Scripts/Bash/Functions</title>
|
|
|
4c79b5 |
|
|
|
63f275 |
<meta name="description" content="CentOS Artwork Repository: 3.37 trunk/Scripts/Bash/Functions">
|
|
|
63f275 |
<meta name="keywords" content="CentOS Artwork Repository: 3.37 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 |
|
|
|
008ee0 |
[ < ]
|
|
|
008ee0 |
[ > ]
|
|
|
4c79b5 |
|
|
|
4c79b5 |
[ << ]
|
|
|
4c79b5 |
[ Up ]
|
|
|
e37211 |
[ >> ]
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
[Top]
|
|
|
4c79b5 |
[Contents]
|
|
|
e37211 |
[Index]
|
|
|
4c79b5 |
[ ? ]
|
|
|
4c79b5 |
|
|
|
63f275 |
|
|
|
008ee0 |
|
|
|
63f275 |
3.37 trunk/Scripts/Bash/Functions
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
008ee0 |
|
|
|
6ba043 |
3.37.1 Goals
|
|
|
6ba043 |
|
|
|
63f275 |
The <tt>`trunk/Scripts/Bash/Functions'</tt> directory exists to organize
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> specific functionalities.
|
|
|
54b5a5 |
|
|
|
6ba043 |
|
|
|
008ee0 |
|
|
|
6ba043 |
3.37.2 Description
|
|
|
6ba043 |
|
|
|
63f275 |
The specific functions of <tt>`centos-art.sh'</tt> script are designed
|
|
|
63f275 |
with "Software Toolbox" philosophy (see (coreutils.info)Toolbox introduction) in mind: each program "should do one
|
|
|
63f275 |
thing well". Inside <tt>`centos-art.sh'</tt> script, each specific
|
|
|
63f275 |
functionality is considered a program that should do one thing well.
|
|
|
63f275 |
Of course, if you find that they still don't do it, feel free to
|
|
|
63f275 |
improve them in order for them to do so.
|
|
|
63f275 |
|
|
|
63f275 |
The specific functions of <tt>`centos-art.sh'</tt> script are organized
|
|
|
63f275 |
inside specific directories under <tt>`trunk/Scripts/Bash/Functions'</tt>
|
|
|
63f275 |
location. Each specific function directory should be named as the
|
|
|
63f275 |
function it represents, with the first letter in uppercase. For
|
|
|
63f275 |
example, if the function name is render , the specific function
|
|
|
63f275 |
directory for it would be <samp>`trunk/Scripts/Bash/Functions/Render'</samp>.
|
|
|
63f275 |
|
|
|
63f275 |
To better understand how specific functions of <tt>`centos-art.sh'</tt>
|
|
|
63f275 |
script are designed, lets create one function which only goal is to
|
|
|
63f275 |
output different kind of greetings to your screen.
|
|
|
63f275 |
|
|
|
63f275 |
When we create specific functions for <tt>`centos-art.sh'</tt> script it
|
|
|
63f275 |
is crucial to know what these functions will do exactly and if there
|
|
|
63f275 |
is any function that already does what we intend to do. If there is no
|
|
|
63f275 |
one, it is good time to create them then. Otherwise, if
|
|
|
63f275 |
functionalities already available don't do what you exactly expect,
|
|
|
63f275 |
contact their authors and work together to improve them.
|
|
|
63f275 |
|
|
|
63f275 |
Tip Join CentOS developers mailing list
|
|
|
63f275 |
centos-art@centos.org to share your ideas.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
It is also worth to know what global functions and variables do we
|
|
|
63f275 |
have available inside <tt>`centos-art.sh'</tt> script, so advantage can be
|
|
|
63f275 |
taken from them. Global variables are defined inside global function
|
|
|
63f275 |
scripts. Global functions scripts are stored immediatly under
|
|
|
63f275 |
<tt>`trunk/Scripts/Bash/Functions'</tt> directory, in files begining with
|
|
|
63f275 |
<samp>`cli'</samp> prefix.
|
|
|
63f275 |
|
|
|
63f275 |
OK, let's begin with our functionality example.
|
|
|
63f275 |
|
|
|
63f275 |
What function name do we use? Well, lets use greet . Note that
|
|
|
63f275 |
<samp>`hello'</samp> word is not a verb; but an expression, a kind of
|
|
|
63f275 |
greeting, an interjection specifically. In contrast, <samp>`greet'</samp> is a
|
|
|
63f275 |
verb and describes what we do when we say <samp>`Hello!'</samp>, <samp>`Hi!'</samp>,
|
|
|
63f275 |
and similar expressions.
|
|
|
63f275 |
|
|
|
63f275 |
So far, we've gathered the following function information:
|
|
|
63f275 |
|
|
|
63f275 |
Name: greet
|
|
|
63f275 |
Path: trunk/Scripts/Bash/Functions/Greet
|
|
|
63f275 |
File: trunk/Scripts/Bash/Functions/Greet/greet.sh
|
|
|
63f275 |
|
|
|
63f275 |
The <tt>`greet.sh'</tt> function script is the first file
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script loads when the <samp>`greet'</samp> functionality
|
|
|
63f275 |
is called using commands like <samp>`centos-art greet --hello='World''</samp>.
|
|
|
63f275 |
The <tt>`greet.sh'</tt> function script contains the greet function
|
|
|
63f275 |
definition.
|
|
|
63f275 |
|
|
|
63f275 |
Inside <tt>`centos-art.sh'</tt> script, as convenction, each function
|
|
|
63f275 |
script has one top commentary, followed by one blank line, and then
|
|
|
63f275 |
one function defintion below it only.
|
|
|
63f275 |
|
|
|
63f275 |
Inside <tt>`centos-art.sh'</tt> script functions, top commentaries have
|
|
|
63f275 |
the following components: the functionality description, one-line for
|
|
|
63f275 |
copyright note with your personal information, the license under
|
|
|
63f275 |
which the function source code is released --the <tt>`centos-art.sh'</tt>
|
|
|
63f275 |
script is released as GPL, so do all its functions--, subversion's
|
|
|
63f275 |
$Id$ keyword which is later expanded by svn propset
|
|
|
63f275 |
command.
|
|
|
63f275 |
|
|
|
63f275 |
In our greet function example, top commentary for
|
|
|
63f275 |
<tt>`greet.sh'</tt> function script would look like the following:
|
|
|
63f275 |
|
|
|
63f275 |
#!/bin/bash
|
|
|
63f275 |
#
|
|
|
63f275 |
# greet.sh -- This function outputs different kind of greetings to
|
|
|
63f275 |
# your screen. Use this function to understand how centos-art.sh
|
|
|
63f275 |
# script specific functionalities work.
|
|
|
63f275 |
#
|
|
|
63f275 |
# Copyright (C) YEAR YOURFULLNAME
|
|
|
63f275 |
#
|
|
|
63f275 |
# This program is free software; you can redistribute it and/or modify
|
|
|
63f275 |
# it under the terms of the GNU General Public License as published by
|
|
|
63f275 |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
63f275 |
# (at your option) any later version.
|
|
|
63f275 |
#
|
|
|
63f275 |
# This program is distributed in the hope that it will be useful, but
|
|
|
63f275 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
63f275 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
63f275 |
# General Public License for more details.
|
|
|
63f275 |
#
|
|
|
63f275 |
# You should have received a copy of the GNU General Public License
|
|
|
63f275 |
# along with this program; if not, write to the Free Software
|
|
|
63f275 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
63f275 |
# USA.
|
|
|
63f275 |
#
|
|
|
63f275 |
# ----------------------------------------------------------------------
|
|
|
63f275 |
# $Id$
|
|
|
63f275 |
# ----------------------------------------------------------------------
|
|
|
63f275 |
|
|
|
63f275 |
After top commentary, separated by one blank line, the greet
|
|
|
63f275 |
function definition would look like the following:
|
|
|
63f275 |
|
|
|
63f275 |
function greet {
|
|
|
63f275 |
|
|
|
63f275 |
# Define global variables.
|
|
|
63f275 |
|
|
|
63f275 |
# Define command-line interface.
|
|
|
63f275 |
greet_getActions
|
|
|
63f275 |
|
|
|
63f275 |
}
|
|
|
63f275 |
|
|
|
63f275 |
The first definition inside greet function, are global
|
|
|
63f275 |
variables that will be available along greet function execution
|
|
|
63f275 |
environment. This time we didn't use global variable definitions for
|
|
|
63f275 |
greet function execution environment, so we left that section
|
|
|
63f275 |
empty.
|
|
|
63f275 |
|
|
|
63f275 |
Later, we call greet_getActions function to define the
|
|
|
63f275 |
command-line interface of greet functionality. The greet
|
|
|
63f275 |
functionality command-line interface defines what and how actions are
|
|
|
63f275 |
performed, based on arguments combination passed to
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
function greet_getActions {
|
|
|
63f275 |
|
|
|
63f275 |
case "$ACTIONNAM" in
|
|
|
63f275 |
|
|
|
63f275 |
--hello )
|
|
|
63f275 |
greet_doHello
|
|
|
63f275 |
;;
|
|
|
63f275 |
|
|
|
63f275 |
--bye )
|
|
|
63f275 |
greet_doBye
|
|
|
63f275 |
;;
|
|
|
63f275 |
|
|
|
63f275 |
* )
|
|
|
63f275 |
cli_printMessage "`gettext "The option provided is not valid."`"
|
|
|
63f275 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
63f275 |
|
|
|
63f275 |
esac
|
|
|
63f275 |
|
|
|
63f275 |
}
|
|
|
63f275 |
|
|
|
63f275 |
The ACTIONNAM global variable is defined in <tt>`cli.sh'</tt>
|
|
|
63f275 |
function script and contains the value passed before the equal sign
|
|
|
63f275 |
(i.e., <samp>`='</samp>) in the second command-line argument of
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script. For example, if the second command-line
|
|
|
63f275 |
argument is <samp>`--hello='World''</samp>, the value of ACTIONNAM
|
|
|
63f275 |
variable would be <samp>`--hello'</samp>. Using this configuration let us
|
|
|
63f275 |
deside which action to perform based on the action name passed to
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script as second argument.
|
|
|
63f275 |
|
|
|
63f275 |
The greet function definition makes available two valid
|
|
|
63f275 |
greetings through <samp>`--hello'</samp> and <samp>`--bye'</samp> options. If no
|
|
|
63f275 |
one of them is provided as second command-line argument, the <samp>`*'</samp>
|
|
|
63f275 |
case is evaluated instead.
|
|
|
63f275 |
|
|
|
63f275 |
The <samp>`*'</samp> case and its two further lines should always be present
|
|
|
63f275 |
in <tt>`_getActions.sh'</tt> function scripts, no matter what specific
|
|
|
63f275 |
functionality you are creating. This convenction helps the user to
|
|
|
63f275 |
find out documentation about current functionality in use.
|
|
|
63f275 |
|
|
|
63f275 |
The greet_doHello and greet_doBye function definitions
|
|
|
63f275 |
are the core of greet specific functionality. In such function
|
|
|
63f275 |
definitions we set what our greet function really does: to
|
|
|
63f275 |
output different kinds of greetings.
|
|
|
63f275 |
|
|
|
63f275 |
function greet_doHello {
|
|
|
63f275 |
|
|
|
63f275 |
cli_printMessage "`gettext "Hello"` $ACTIONVAL"
|
|
|
63f275 |
|
|
|
63f275 |
}
|
|
|
63f275 |
|
|
|
63f275 |
The greet_doHello function definition is stored in
|
|
|
63f275 |
<tt>`greet_doHello.sh'</tt> function script.
|
|
|
63f275 |
|
|
|
63f275 |
function greet_doBye {
|
|
|
63f275 |
|
|
|
63f275 |
cli_printMessage "`gettext "Goodbye"` $ACTIONVAL"
|
|
|
63f275 |
|
|
|
63f275 |
}
|
|
|
63f275 |
|
|
|
63f275 |
The greet_doBye function definition is stored in the
|
|
|
63f275 |
<tt>`greet_doBye.sh'</tt> function script.
|
|
|
63f275 |
|
|
|
63f275 |
Both <tt>`greet_doHello.sh'</tt> and <tt>`greet_doBye.sh'</tt> function
|
|
|
63f275 |
scripts are stored inside greet 's function directory path (i.e.
|
|
|
63f275 |
<tt>`trunk/Scripts/Bash/Functions/Greet'</tt>).
|
|
|
63f275 |
|
|
|
63f275 |
The ACTIONVAL global variable is defined in <tt>`cli.sh'</tt>
|
|
|
63f275 |
function script and contains the value passed after the equal sign
|
|
|
63f275 |
(i.e., <samp>`='</samp>) in the second command-line argument of
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script. For example, if the second command-line
|
|
|
63f275 |
argument is <samp>`--hello='World''</samp>, the value of ACTIONVAL
|
|
|
63f275 |
variable would be <samp>`World'</samp> without quotes.
|
|
|
63f275 |
|
|
|
63f275 |
Let's see how greet specific functionality files are organzied
|
|
|
63f275 |
under greet 's function directory. To see file organization we
|
|
|
63f275 |
use the tree command:
|
|
|
63f275 |
|
|
|
63f275 |
trunk/Scripts/Bash/Functions/Greet
|
|
|
63f275 |
|-- greet_doBye.sh
|
|
|
63f275 |
|-- greet_doHello.sh
|
|
|
63f275 |
|-- greet_getActions.sh
|
|
|
63f275 |
`-- greet.sh
|
|
|
63f275 |
|
|
|
63f275 |
To try the greet specific functionality we've just created,
|
|
|
63f275 |
pass the function name (i.e., <samp>`greet'</samp>) as first argument to
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script, and any of the valid options as second
|
|
|
63f275 |
argument. Some examples are illustrated below:
|
|
|
63f275 |
|
|
|
63f275 |
[centos@projects ~]$ centos-art greet --hello='World'
|
|
|
63f275 |
Hello World
|
|
|
63f275 |
[centos@projects ~]$ centos-art greet --bye='World'
|
|
|
63f275 |
Goodbye World
|
|
|
63f275 |
[centos@projects ~]$
|
|
|
63f275 |
|
|
|
63f275 |
The word <samp>`World'</samp> in the examples above can be anything. In fact,
|
|
|
63f275 |
change it to have a little fun.
|
|
|
63f275 |
|
|
|
63f275 |
Now that we have a specific function that works as we expect, it is
|
|
|
63f275 |
time to document it. To document greet specific functionality,
|
|
|
831389 |
we use its directory path and the manual functionality
|
|
|
3d6160 |
(-- Removed(pxref:trunk Scripts Bash Functions Manual) --) of <tt>`centos-art.sh'</tt>
|
|
|
831389 |
script, just as the following command illustrates:
|
|
|
63f275 |
|
|
|
63f275 |
centos-art help --edit=trunk/Scripts/Bash/Functions/Greet
|
|
|
63f275 |
|
|
|
63f275 |
Now that we have documented our function, it is time to translate its
|
|
|
63f275 |
output messages to different languages. To translate specific
|
|
|
63f275 |
functionality output messages to different languages we use the
|
|
|
e68a7a |
locale functionality (see section trunk/Scripts/Bash/Functions/Locale) of <tt>`centos-art.sh'</tt> script, just as the following command
|
|
|
63f275 |
illustrates:
|
|
|
63f275 |
|
|
|
63f275 |
centos-art locale --edit
|
|
|
63f275 |
|
|
|
63f275 |
Warning To translate output messages in different languages,
|
|
|
63f275 |
your system locale information --as in LANG environment
|
|
|
63f275 |
variable-- must be set to that locale you want to produce translated
|
|
|
63f275 |
messages for. For example, if you want to produce translated messages
|
|
|
63f275 |
for Spanish language, your system locale information must be set to
|
|
|
63f275 |
<samp>`es_ES.UTF-8'</samp> or similar.
|
|
|
63f275 |
|
|
|
6ba043 |
|
|
|
63f275 |
Well, it seems that our example is rather complete by now.
|
|
|
63f275 |
|
|
|
63f275 |
In greet function example we've described so far, we only use
|
|
|
63f275 |
cli_printMessage global function in action specific function
|
|
|
63f275 |
definitions in order to print a message simply, but more interesting
|
|
|
63f275 |
things can be achieved inside action specific function definitions.
|
|
|
63f275 |
For example, if you pass a directory path as second argument option
|
|
|
63f275 |
value, you could retrive a list of files from therein, and process
|
|
|
63f275 |
them. If the list of files turns too long or you just want to control
|
|
|
63f275 |
which files to process, you could add the third argument in the form
|
|
|
63f275 |
<samp>`--filter='regex''</samp> and reduce the amount of files to process
|
|
|
63f275 |
using a regular expression pattern.
|
|
|
63f275 |
|
|
|
63f275 |
The greet function described in this section may serve you as
|
|
|
63f275 |
an introduction to understand how specific functionalities work inside
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script. With some of luck this introduction will
|
|
|
63f275 |
also serve you as motivation to create your own <tt>`centos-art.sh'</tt>
|
|
|
63f275 |
script specific functionalities.
|
|
|
63f275 |
|
|
|
63f275 |
By the way, the greet functionality doesn't exist inside
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script yet. Would you like to create it?
|
|
|
63f275 |
|
|
|
6ba043 |
|
|
|
008ee0 |
|
|
|
6ba043 |
3.37.3 Usage
|
|
|
6ba043 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
3.37.3.1 Global variables
|
|
|
63f275 |
|
|
|
63f275 |
The following global variables of <tt>`centos-art.sh'</tt> script, are
|
|
|
63f275 |
available for you to use inside specific functions:
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Variable:</u> TEXTDOMAIN
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Default domain used to retrieve translated messages. This value is set
|
|
|
63f275 |
in <tt>`initFunctions.sh'</tt> and shouldn't be changed.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Variable:</u> TEXTDOMAINDIR
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Default directory used to retrieve translated messages. This value is
|
|
|
63f275 |
set in <tt>`initFunctions.sh'</tt> and shouldn't be changed.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Variable:</u> FUNCNAM
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Define function name.
|
|
|
63f275 |
|
|
|
63f275 |
Function names associate sets of actions. There is one set of actions
|
|
|
63f275 |
for each unique function name inside <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
Dunction names are passed as first argument in <tt>`centos-art.sh'</tt>
|
|
|
63f275 |
command-line interface. For example, in the command <samp>`centos-art
|
|
|
63f275 |
render --entry=path/to/dir --filter=regex'</samp>, the ACTION passed to
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script is <samp>`render'</samp>.
|
|
|
63f275 |
|
|
|
63f275 |
When first argument is not provided, the <tt>`centos-art.sh'</tt> script
|
|
|
63f275 |
immediatly ends its execution.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Variable:</u> ACTIONNAM
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Define action name.
|
|
|
63f275 |
|
|
|
63f275 |
Each action name identifies an specific action to perform, inside an
|
|
|
63f275 |
specific function.
|
|
|
63f275 |
|
|
|
63f275 |
Action name names aare passed as second argument in
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> command-line interface. For example, in the
|
|
|
63f275 |
command <samp>`centos-art render --entry=path/to/dir --filter=regex'</samp>,
|
|
|
63f275 |
the ACTIONNAM passed to <tt>`centos-art.sh'</tt> script is
|
|
|
63f275 |
<samp>`--entry'</samp>.
|
|
|
63f275 |
|
|
|
63f275 |
When second argument is not provided, the <tt>`centos-art.sh'</tt> script
|
|
|
63f275 |
immediatly ends its execution.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Variable:</u> ACTIONVAL
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Define action value.
|
|
|
63f275 |
|
|
|
63f275 |
Action values are associated to just one action name. Action values
|
|
|
63f275 |
contain the repository entry over which its associated action will be
|
|
|
63f275 |
performed in. Repository entries can be directories, files, or URLs
|
|
|
63f275 |
refering the repository structure.
|
|
|
63f275 |
|
|
|
63f275 |
When action value is not specified as repository entry, the
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script evaluates the current directory it was
|
|
|
63f275 |
executed from. If such directory is under the repository structure
|
|
|
63f275 |
(i.e., <tt>`/home/centos/artwork/'</tt>), the <tt>`centos-art.sh'</tt> script
|
|
|
63f275 |
uses that directory as value to ACTIONVAL variable. Otherwise,
|
|
|
63f275 |
if outside the repository structure, the <tt>`centos-art.sh'</tt> script
|
|
|
63f275 |
prints the message <samp>`The path provided can't be processed.'</samp> and,
|
|
|
63f275 |
after it, immediatly ends script execution.
|
|
|
63f275 |
|
|
|
63f275 |
Default action value is passed as second argument in
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> command-line interface. For example, in the
|
|
|
63f275 |
command <samp>`centos-art render --entry=path/to/dir --filter=regex'</samp>,
|
|
|
63f275 |
the ACTIONVAL passed to <tt>`centos-art.sh'</tt> script is
|
|
|
63f275 |
<samp>`path/to/dir'</samp>.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Variable:</u> REGEX
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Define regular expression used as pattern to build the list of files
|
|
|
63f275 |
to process.
|
|
|
63f275 |
|
|
|
63f275 |
By default, REGEX variable is set to .+ to match all
|
|
|
63f275 |
files.
|
|
|
63f275 |
|
|
|
63f275 |
Functions that need to build a list of files to process use the option
|
|
|
63f275 |
<samp>`--filter'</samp> to redefine REGEX variable default value, and
|
|
|
63f275 |
so, control the amount of files to process.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Variable:</u> ARGUMENTS
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Define optional arguments.
|
|
|
63f275 |
|
|
|
63f275 |
Optional arguments, inside <tt>`centos-art.sh'</tt> script, are considered
|
|
|
63f275 |
as all command-line arguments passed to <tt>`centos-art.sh'</tt> script,
|
|
|
63f275 |
from third argument position on. For example, in the command
|
|
|
63f275 |
<samp>`centos-art render --entry=path/to/dir --filter=regex'</samp> , the
|
|
|
63f275 |
optional arguments are from <samp>`--filter=regex'</samp> argument on.
|
|
|
63f275 |
|
|
|
63f275 |
Optional arguments are parsed using getopt command through
|
|
|
63f275 |
the following base construction:
|
|
|
63f275 |
|
|
|
63f275 |
# Define short options we want to support.
|
|
|
63f275 |
local ARGSS=""
|
|
|
63f275 |
|
|
|
63f275 |
# Define long options we want to support.
|
|
|
63f275 |
local ARGSL="filter:,to:"
|
|
|
63f275 |
|
|
|
63f275 |
# Parse arguments using getopt(1) command parser.
|
|
|
63f275 |
cli_doParseArguments
|
|
|
63f275 |
|
|
|
63f275 |
# Reset positional parameters using output from (getopt) argument
|
|
|
63f275 |
# parser.
|
|
|
63f275 |
eval set -- "$ARGUMENTS"
|
|
|
63f275 |
|
|
|
63f275 |
# Define action to take for each option passed.
|
|
|
63f275 |
while true; do
|
|
|
63f275 |
case "$1" in
|
|
|
63f275 |
--filter )
|
|
|
63f275 |
REGEX="$2"
|
|
|
63f275 |
shift 2
|
|
|
63f275 |
;;
|
|
|
63f275 |
--to )
|
|
|
63f275 |
TARGET="$2"
|
|
|
63f275 |
shift 2
|
|
|
63f275 |
;;
|
|
|
63f275 |
* )
|
|
|
63f275 |
break
|
|
|
63f275 |
esac
|
|
|
63f275 |
done
|
|
|
63f275 |
|
|
|
63f275 |
Optional arguments provide support to command options inside
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script. For instance, consider the Subversion
|
|
|
63f275 |
(svn ) command, where there are many options (e.g.,
|
|
|
63f275 |
<samp>`copy'</samp>, <samp>`delete'</samp>, <samp>`move'</samp>, etc), and inside each
|
|
|
63f275 |
option there are several modifiers (e.g., <samp>`--revision'</samp>,
|
|
|
63f275 |
<samp>`--message'</samp>, <samp>`--username'</samp>, etc.) that can be combined one
|
|
|
63f275 |
another in their short or long variants.
|
|
|
63f275 |
|
|
|
63f275 |
The ARGUMENTS variable is used to store arguments passed from
|
|
|
63f275 |
command-line for later use inside <tt>`centos-art.sh'</tt> script. Storing
|
|
|
63f275 |
arguments is specially useful when we want to run a command with some
|
|
|
63f275 |
specific options from them. Consider the following command:
|
|
|
63f275 |
|
|
|
63f275 |
centos-art path --copy=SOURCE --to=TARGET --message="The commit message goes here." --username='johndoe'
|
|
|
63f275 |
|
|
|
63f275 |
In the above command, the <samp>`--message'</samp>, and <samp>`--username'</samp>
|
|
|
63f275 |
options are specific to svn copy command. In such cases,
|
|
|
63f275 |
options are not interpreted by <tt>`centos-art.sh'</tt> script itself.
|
|
|
63f275 |
Instead, the <tt>`centos-art.sh'</tt> script uses getopt to
|
|
|
63f275 |
retrive them and stores them in the ARGUMENT variable for later
|
|
|
63f275 |
use, as described in the following command:
|
|
|
63f275 |
|
|
|
63f275 |
# Build subversion command to duplicate locations inside the
|
|
|
63f275 |
# workstation.
|
|
|
63f275 |
eval svn copy $SOURCE $TARGET --quiet $ARGUMENTS
|
|
|
63f275 |
|
|
|
63f275 |
When getopt parses ARGUMENTS, we may use short options
|
|
|
63f275 |
(e.g., <samp>`-m'</samp>) or long options (e.g., <samp>`--message'</samp>). When
|
|
|
63f275 |
we use short options, arguments are separated by one space from the
|
|
|
63f275 |
option (e.g., <samp>`-m 'This is a commit message.''</samp>). When we use
|
|
|
63f275 |
long options arguments are separated by an equal sign (<samp>`='</samp>)
|
|
|
63f275 |
(e.g., <samp>`--message='This is a commit message''</samp>).
|
|
|
63f275 |
|
|
|
63f275 |
In order for getopt to parse ARGUMENTS correctly, it
|
|
|
63f275 |
is required to provide the short and long definition of options that
|
|
|
63f275 |
will be passed or at least supported by the command performing the
|
|
|
63f275 |
final action the function script exists for.
|
|
|
63f275 |
|
|
|
63f275 |
As convenction, inside <tt>`centos-art.sh'</tt> script, short option
|
|
|
63f275 |
definitions are set in the ARGSS variable; and long option
|
|
|
63f275 |
definitions are set in the ARGSL variable.
|
|
|
63f275 |
|
|
|
63f275 |
When you define short and long options, it may be needed to define
|
|
|
63f275 |
which of these option arguments are required and which not. To define
|
|
|
63f275 |
an option argument as required, you need to set one colon <samp>`:'</samp>
|
|
|
63f275 |
after the option definition (e.g., <samp>`-o m: -l message:'</samp>). On
|
|
|
63f275 |
the other hand, to define an option argument as not required, you need
|
|
|
63f275 |
to set two colons <samp>`::'</samp> after the option definition (e.g.,
|
|
|
63f275 |
<samp>`-o m:: -l message::'</samp>).
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Variable:</u> EDITOR
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Default text editor.
|
|
|
63f275 |
|
|
|
63f275 |
The <tt>`centos-art.sh'</tt> script uses default text EDITOR to edit
|
|
|
63f275 |
pre-commit subversion messages, translation files, configuration
|
|
|
63f275 |
files, script files, and similar text-based files.
|
|
|
63f275 |
|
|
|
63f275 |
If EDITOR environment variable is not set, <tt>`centos-art.sh'</tt>
|
|
|
63f275 |
script uses <tt>`/usr/bin/vim'</tt> as default text editor. Otherwise, the
|
|
|
63f275 |
following values are recognized by <tt>`centos-art.sh'</tt> script:
|
|
|
63f275 |
|
|
|
54b5a5 |
|
|
|
63f275 |
<tt>`/usr/bin/vim'</tt>
|
|
|
63f275 |
<tt>`/usr/bin/emacs'</tt>
|
|
|
63f275 |
<tt>`/usr/bin/nano'</tt>
|
|
|
54b5a5 |
|
|
|
008ee0 |
|
|
|
63f275 |
If no one of these values is set in EDITOR environment variable,
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> uses <tt>`/usr/bin/vim'</tt> text editor by default.
|
|
|
63f275 |
|
|
|
008ee0 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
3.37.3.2 Global functions
|
|
|
63f275 |
|
|
|
63f275 |
The following global functions of <tt>`centos-art.sh'</tt> script are
|
|
|
63f275 |
available for you to use inside specific functions:
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_commitRepoChanges [LOCATION]
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Syncronize changes between repository and working copy.
|
|
|
63f275 |
|
|
|
63f275 |
The cli_commitRepoChanges function uses the value of
|
|
|
63f275 |
LOCATION argument as reference to perform change verification
|
|
|
63f275 |
inside the working copy using subversion commands. If LOCATION
|
|
|
63f275 |
argument is not specified as cli_commitRepoChanges first
|
|
|
63f275 |
argument, the ACTIONVAL variable is used as reference instead.
|
|
|
63f275 |
|
|
|
63f275 |
The cli_commitRepoChanges function brings changes from the
|
|
|
63f275 |
repository to the working copy--using svn update --, checks
|
|
|
63f275 |
the working copy changes--using svn status command--,
|
|
|
63f275 |
prints status report--using both svn update and
|
|
|
63f275 |
svn status commands output, and finally, commits recent
|
|
|
63f275 |
changes from the working copy up to the repository--using
|
|
|
63f275 |
svn commit command--.
|
|
|
63f275 |
|
|
|
63f275 |
Previous to commit the working copy changes up to the repository, the
|
|
|
63f275 |
cli_commitRepoChanges function asks you to verify
|
|
|
63f275 |
changes--using svn diff command--, and later, another
|
|
|
63f275 |
confirmation question is shown to be sure you really want to commit
|
|
|
63f275 |
changes up to central repository.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
--> Bringing changes from the repository into the working copy
|
|
|
63f275 |
--> Checking changes in the working copy
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
Added 0 file from the repository.
|
|
|
63f275 |
Deleted 0 file from the repository.
|
|
|
63f275 |
Updated 0 file from the repository.
|
|
|
63f275 |
Conflicted 0 file from the repository.
|
|
|
63f275 |
Merged 0 file from the repository.
|
|
|
63f275 |
Modified 4 files from the working copy.
|
|
|
63f275 |
Unversioned 0 file from the working copy.
|
|
|
63f275 |
Deleted 0 file from the working copy.
|
|
|
63f275 |
Added 0 file from the working copy.
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
|
|
|
63f275 |
Figure 3.9: The cli_commitRepoChanges function output.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Call the cli_commitRepoChanges function before or/and after
|
|
|
63f275 |
functions that modify files or directories inside the working copy as
|
|
|
63f275 |
you may need to.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_checkFiles FILE [TYPE]
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Verify files existence.
|
|
|
63f275 |
|
|
|
63f275 |
cli_checkFiles receives a FILE absolute path and performs
|
|
|
63f275 |
file verification as specified in TYPE. When TYPE is not
|
|
|
63f275 |
specified, cli_checkFiles verifies FILE existence, no
|
|
|
63f275 |
matter what kind of file it be. If TYPE is specified, use one
|
|
|
63f275 |
of the following values:
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`d'</samp>
|
|
|
63f275 |
<samp>`directory'</samp>
|
|
|
63f275 |
Ends script execution if FILE is not a directory.
|
|
|
63f275 |
|
|
|
63f275 |
When you verify directories with cli_checkFiles, if directory doesn't
|
|
|
63f275 |
exist, <tt>`centos-art.sh'</tt> script asks you for confirmation in order
|
|
|
63f275 |
to create that directory. If you answer positively,
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script creates that directory and continues
|
|
|
63f275 |
script flows normally. Otherwise, if you answer negatively,
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> ends script execution with an error and
|
|
|
63f275 |
documentation message.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`f'</samp>
|
|
|
63f275 |
<samp>`regular-file'</samp>
|
|
|
63f275 |
Ends script execution if FILE is not a regular file.
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`h'</samp>
|
|
|
63f275 |
<samp>`symbolic-link'</samp>
|
|
|
63f275 |
Ends script execution if FILE is not a symbolic link.
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`x'</samp>
|
|
|
63f275 |
<samp>`execution'</samp>
|
|
|
63f275 |
Ends script execution if FILE is not executable.
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`fh'</samp>
|
|
|
63f275 |
Ends script execution if FILE is neither a regular file or a
|
|
|
63f275 |
symbolic link.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
As default behaviour, if FILE passes all verifications,
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script continues with its normal flow.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_getCountryCodes [FILTER]
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Output country codes.
|
|
|
63f275 |
|
|
|
63f275 |
The cli_getCountryCodes function outputs a list with country
|
|
|
63f275 |
codes as defined in ISO3166 standard. When FILTER is provided,
|
|
|
63f275 |
cli_getCountryCodes outputs country codes that match
|
|
|
63f275 |
FILTER regular expression pattern.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_getCountryName [FILTER]
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Output country names.
|
|
|
63f275 |
|
|
|
63f275 |
The cli_getCountryName function reads one language locale code
|
|
|
63f275 |
in the format LL_CC and outputs the name of its related country as in
|
|
|
63f275 |
ISO3166. If filter is specified, cli_getCountryName returns the
|
|
|
63f275 |
country name that matches the locale code specified in FILTER,
|
|
|
63f275 |
exactly.
|
|
|
63f275 |
|
|
|
63f275 |
The cli_getCountryName function outputs country name supported
|
|
|
63f275 |
by <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_getCurrentLocale
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Output current locale used by <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
The cli_getCurrentLocale function uses LANG environment
|
|
|
63f275 |
variable to build a locale pattern that is later applied to
|
|
|
63f275 |
cli_getLocales function output in order to return the current
|
|
|
63f275 |
locale that <tt>`centos-art.sh'</tt> script works with.
|
|
|
63f275 |
|
|
|
63f275 |
The current locale information, returned by
|
|
|
63f275 |
cli_getCurrentLocale , is output from more specific to less
|
|
|
63f275 |
specific. For example, if <samp>`en_GB'</samp> locale exists in
|
|
|
63f275 |
cli_getLocales function output, the <samp>`en_GB'</samp> locale would
|
|
|
63f275 |
take precedence before <samp>`en'</samp> locale.
|
|
|
63f275 |
|
|
|
63f275 |
Locale precedence selection is quite important in order to define the
|
|
|
63f275 |
locale type we use for message translations. For example, if
|
|
|
63f275 |
<samp>`en_GB'</samp> is used, we are also saying that no common language
|
|
|
63f275 |
specification is used for English language (i.e., <samp>`en'</samp>). Instead,
|
|
|
63f275 |
we are using English non-common country-specific language
|
|
|
63f275 |
specifications like <samp>`en_AU'</samp>, <samp>`en_BW'</samp>, <samp>`en_GB'</samp>,
|
|
|
63f275 |
<samp>`en_US'</samp>, etc., for message translations.
|
|
|
63f275 |
|
|
|
63f275 |
Use cli_getCurrentLocale function to know what current locale
|
|
|
63f275 |
information to use inside <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
The cli_getCurrentLocale function outputs current locale used
|
|
|
63f275 |
by <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_getLangCodes [FILTER]
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Output language codes.
|
|
|
63f275 |
|
|
|
63f275 |
cli_getLangCodes function outputs a list of language codes as
|
|
|
63f275 |
defined in ISO639 standard. When FILTER is provided,
|
|
|
63f275 |
cli_getLangCodes outputs language codes that match FILTER
|
|
|
63f275 |
regular expression pattern.
|
|
|
63f275 |
|
|
|
63f275 |
The cli_getLangCodes function outputs language codes supported
|
|
|
63f275 |
by <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_getLangName [FILTER]
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Output language names.
|
|
|
63f275 |
|
|
|
63f275 |
cli_getLangName function reads one language locale code in the
|
|
|
63f275 |
format LL_CC and outputs the language related name as in ISO639. If
|
|
|
63f275 |
filter is specified, cli_getLangName returns the language name
|
|
|
63f275 |
that matches the locale code specified in FILTER, exactly.
|
|
|
63f275 |
|
|
|
63f275 |
The cli_getLangName function outputs language names supported
|
|
|
63f275 |
by <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_getLocales
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Output locale codes supported by <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
Occasionally, you use cli_getLocales function to add locale
|
|
|
63f275 |
information in non-common country-specific language (<samp>`LL_CC'</samp>)
|
|
|
63f275 |
format for those languages (e.g., <samp>`bn_IN'</samp>, <samp>`pt_BR'</samp>, etc.)
|
|
|
63f275 |
which locale differences cannot be solved using common language
|
|
|
63f275 |
specifications (<samp>`LL'</samp>) into one unique common locale specification
|
|
|
63f275 |
(e.g., <samp>`bn'</samp>, <samp>`pt'</samp>, etc.).
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_getRepoName NAME TYPE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Sanitate file names.
|
|
|
63f275 |
|
|
|
63f275 |
Inside <tt>`centos-art.sh'</tt> script, specific functionalities rely both
|
|
|
63f275 |
in cli_getRepoName and repository file system organization to
|
|
|
63f275 |
achieve their goals. Consider cli_getRepoName function as
|
|
|
63f275 |
central place to manage file name convenctions for other functions
|
|
|
63f275 |
inside <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
Important cli_getRepoName function doesn't verify file
|
|
|
63f275 |
or directory existence, for that purpose use cli_checkFiles
|
|
|
63f275 |
function instead.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
The NAME variable contains the file name or directory name you
|
|
|
63f275 |
want to sanitate.
|
|
|
63f275 |
|
|
|
63f275 |
The TYPE variable can be one of the following values:
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`d'</samp>
|
|
|
63f275 |
<samp>`directory'</samp>
|
|
|
63f275 |
Sanitate directory NAMEs.
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`f'</samp>
|
|
|
63f275 |
<samp>`regular-file'</samp>
|
|
|
63f275 |
Sanitate regular file NAMEs.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Use cli_getRepoName function to sanitate file names and
|
|
|
63f275 |
directory names before their utilization.
|
|
|
63f275 |
|
|
|
63f275 |
Use cli_getRepoName when you need to change file name
|
|
|
63f275 |
convenctions inside <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
When changing file name convenctions inside cli_getRepoName
|
|
|
63f275 |
what you are really changing is the way functions interpret repository
|
|
|
63f275 |
file system organization. In order to a complete file name convenction
|
|
|
63f275 |
change, you also need to change file names and directory names inside
|
|
|
63f275 |
repository file system organization, just as you did in
|
|
|
63f275 |
cli_getRepoName function.
|
|
|
63f275 |
|
|
|
e37211 |
Note See section trunk/Scripts/Bash/Functions/Path, for more
|
|
|
63f275 |
information on how to rename files and directories massively inside
|
|
|
63f275 |
repository file system organization.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_getTemporalFile NAME
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Output absolute path to temporal file NAME.
|
|
|
63f275 |
|
|
|
63f275 |
cli_getTemporalFile uses <tt>`/tmp'</tt> directory as source
|
|
|
63f275 |
location to store temporal files, the <tt>`centos-art.sh'</tt> script
|
|
|
63f275 |
name, and a random identification string to let you run more than one
|
|
|
63f275 |
<tt>`centos-art.sh'</tt> script simultaneously on the same user session.
|
|
|
63f275 |
For example, due the following temporal file defintion:
|
|
|
63f275 |
|
|
|
63f275 |
cli_getTemporalFile $FILE
|
|
|
63f275 |
|
|
|
63f275 |
If FILE name is <tt>`instance.svg'</tt> and unique random string is
|
|
|
63f275 |
<samp>`f16f7b51-ac12-4b7f-9e66-72df847f12de'</samp>, the final temporal file,
|
|
|
63f275 |
built from previous temporal file definition, would be:
|
|
|
63f275 |
|
|
|
63f275 |
/tmp/centos-art.sh-f16f7b51-ac12-4b7f-9e66-72df847f12de-instance.svg
|
|
|
63f275 |
|
|
|
63f275 |
When you use cli_getTemporalFile function to create temporal
|
|
|
63f275 |
files, be sure to remove temporal files created once you've ended up
|
|
|
63f275 |
with them. For example, consider the following construction:
|
|
|
63f275 |
|
|
|
63f275 |
for FILE in $FILES;do
|
|
|
63f275 |
|
|
|
63f275 |
# Initialize temporal instance of file.
|
|
|
63f275 |
INSTANCE=$(cli_getTemporalFile $FILE)
|
|
|
63f275 |
|
|
|
63f275 |
# Do something ...
|
|
|
63f275 |
|
|
|
63f275 |
# Remove temporal instance of file.
|
|
|
63f275 |
if [[ -f $INSTANCE ]];then
|
|
|
63f275 |
rm $INSTANCE
|
|
|
63f275 |
fi
|
|
|
63f275 |
|
|
|
63f275 |
done
|
|
|
63f275 |
|
|
|
63f275 |
Use cli_getTemporalFile function whenever you need to create
|
|
|
63f275 |
temporal files inside <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_getThemeName
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Output theme name.
|
|
|
63f275 |
|
|
|
63f275 |
In order for cli_getThemeName function to extract theme name
|
|
|
63f275 |
correctly, the ACTIONVAL variable must contain a directory path
|
|
|
63f275 |
under <tt>`trunk/Identity/Themes/Motifs/'</tt> directory structure.
|
|
|
63f275 |
Otherwise, cli_getThemeName returns an empty string.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<u>Function:</u> cli_printMessage MESSAGE [FORMAT]
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Give format to output messages.
|
|
|
63f275 |
|
|
|
63f275 |
When FORMAT is not specified, cli_printMessage outputs
|
|
|
63f275 |
information just as it was passed in MESSAGE variable.
|
|
|
63f275 |
Otherwise, FORMAT can take one of the following values:
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsHeadingLine'</samp>
|
|
|
63f275 |
To print heading messages.
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
$MESSAGE
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsWarningLine'</samp>
|
|
|
63f275 |
To print warning messages.
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
WARNING: $MESSAGE
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsNoteLine'</samp>
|
|
|
63f275 |
To print note messages.
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
NOTE: $MESSAGE
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsUpdatingLine'</samp>
|
|
|
63f275 |
To print <samp>`Updating'</samp> messages using two-columns format.
|
|
|
63f275 |
Updating $MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsRemovingLine'</samp>
|
|
|
63f275 |
To print <samp>`Removing'</samp> messages using two-columns format.
|
|
|
63f275 |
Removing $MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsCheckingLine'</samp>
|
|
|
63f275 |
To print <samp>`Checking'</samp> messages using two-columns format.
|
|
|
63f275 |
Checking $MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsCreatingLine'</samp>
|
|
|
63f275 |
To print <samp>`Creating'</samp> messages using two-columns format.
|
|
|
63f275 |
Creating $MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsSavedAsLine'</samp>
|
|
|
63f275 |
To print <samp>`Saved as'</samp> messages using two-columns format.
|
|
|
63f275 |
Saved as $MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsLinkToLine'</samp>
|
|
|
63f275 |
To print <samp>`Linked to'</samp> messages using two-columns format.
|
|
|
63f275 |
Linked to $MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsMovedToLine'</samp>
|
|
|
63f275 |
To print <samp>`Moved to'</samp> messages using two-columns format.
|
|
|
63f275 |
Moved to $MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsTranslationLine'</samp>
|
|
|
63f275 |
To print <samp>`Translation'</samp> messages using two-columns format.
|
|
|
63f275 |
Translation $MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsConfigurationLine'</samp>
|
|
|
63f275 |
To print <samp>`Configuration'</samp> messages using two-columns format.
|
|
|
63f275 |
Configuration $MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsResponseLine'</samp>
|
|
|
63f275 |
To print response messages using one-column format.
|
|
|
63f275 |
--> $MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsRequestLine'</samp>
|
|
|
63f275 |
To print request messages using one-column format. Request messages
|
|
|
63f275 |
supress the trailing newline character from final output.
|
|
|
63f275 |
$MESSAGE
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsYesOrNoRequestLine'</samp>
|
|
|
63f275 |
To print <samp>`yes or no'</samp> request messages using one-column format. If
|
|
|
63f275 |
something different from <samp>`y'</samp> is answered (when using
|
|
|
63f275 |
en_US.UTF-8 locale), script execution ends immediatly.
|
|
|
63f275 |
|
|
|
63f275 |
$MESSAGE [y/N]:
|
|
|
63f275 |
|
|
|
63f275 |
When you are using <tt>`centos-art.sh'</tt> script in a locale different
|
|
|
63f275 |
from en_US.UTF-8 , confirmation answer may be different from
|
|
|
63f275 |
<samp>`y'</samp>. For example, if you are using es_ES.UTF-8 locale, the
|
|
|
63f275 |
confirmation question would look like:
|
|
|
63f275 |
|
|
|
63f275 |
$MESSAGE [s/N]:
|
|
|
63f275 |
|
|
|
63f275 |
and the confirmation answer would be <samp>`s'</samp>, as it is on Spanish
|
|
|
63f275 |
<samp>`sí'</samp> word.
|
|
|
63f275 |
|
|
|
63f275 |
Definition of which confirmation word to use is set on translation
|
|
|
e68a7a |
messages for your specific locale information. See section trunk/Scripts/Bash/Functions/Locale, for more information about locale-specific
|
|
|
63f275 |
translation messages.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsToKnowMoreLine'</samp>
|
|
|
63f275 |
To standardize <samp>`to know more, run the following command:'</samp>
|
|
|
63f275 |
messages. When the <samp>`AsToKnowMoreLine'</samp> option is used, the
|
|
|
63f275 |
MESSAGE value should be set to "$(caller)" . caller
|
|
|
63f275 |
is a Bash builtin that returns the context of the current subroutine
|
|
|
63f275 |
call. <samp>`AsToKnowMoreLine'</samp> option uses caller builtin
|
|
|
63f275 |
output to build documentation entries dynamically.
|
|
|
63f275 |
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
To know more, run the following command:
|
|
|
63f275 |
centos-art help --read='path/to/dir'
|
|
|
63f275 |
----------------------------------------------------------------------
|
|
|
63f275 |
|
|
|
63f275 |
Use <samp>`AsToKnowMoreLine'</samp> option after errors and for intentional
|
|
|
63f275 |
script termination.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
<samp>`AsRegularLine'</samp>
|
|
|
63f275 |
To standardize regular messages using one-column format.
|
|
|
63f275 |
|
|
|
63f275 |
When MESSAGE contains a colon inside (e.g., <samp>`description:
|
|
|
63f275 |
message'</samp>), the cli_printMessage function outputs MESSAGE
|
|
|
63f275 |
using two-columns format.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Tip To improve two-columns format, change the following file:
|
|
|
63f275 |
trunk/Scripts/Bash/Styles/output_forTwoColumns.awk
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
Use cli_printMessage function whenever you need to output
|
|
|
63f275 |
information from <tt>`centos-art.sh'</tt> script.
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
3.37.3.3 Specific functions
|
|
|
63f275 |
|
|
|
63f275 |
The following specific functions of <tt>`centos-art.sh'</tt> script, are
|
|
|
63f275 |
available for you to use:
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
e68a7a |
3.38 trunk/Scripts/Bash/Functions/Html
|
|
|
63f275 |
|
|
|
e68a7a |
3.39 trunk/Scripts/Bash/Functions/Locale
|
|
|
63f275 |
|
|
|
e37211 |
3.40 trunk/Scripts/Bash/Functions/Path
|
|
|
63f275 |
|
|
|
e37211 |
3.41 trunk/Scripts/Bash/Functions/Render
|
|
|
63f275 |
|
|
|
e37211 |
3.42 trunk/Scripts/Bash/Functions/Render/Config
|
|
|
63f275 |
|
|
|
e37211 |
3.43 trunk/Scripts/Bash/Functions/Shell
|
|
|
63f275 |
|
|
|
e37211 |
3.44 trunk/Scripts/Bash/Functions/Svg
|
|
|
63f275 |
|
|
|
e37211 |
3.45 trunk/Scripts/Bash/Functions/Verify
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
6ba043 |
3.37.4 See also
|
|
|
6ba043 |
|
|
|
63f275 |
|
|
|
63f275 |
3.36 trunk/Scripts/Bash
|
|
|
63f275 |
|
|
|
e37211 |
3.46 trunk/Scripts/Bash/Locale
|
|
|
63f275 |
|
|
|
63f275 |
|
|
|
4c79b5 |
|
|
|
5fb024 |
|
|
|
4c79b5 |
|
|
|
63f275 |
[ < ]
|
|
|
63f275 |
[ > ]
|
|
|
4c79b5 |
|
|
|
4c79b5 |
[ << ]
|
|
|
008ee0 |
[ Up ]
|
|
|
e37211 |
[ >> ]
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
<font size="-1">
|
|
|
008ee0 |
This document was generated on December, 2 2010 using texi2html 1.76.
|
|
|
4c79b5 |
</font>
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
</body>
|
|
|
4c79b5 |
</html>
|