|
|
cc8089 |
@subsection Goals
|
|
|
cc8089 |
|
|
|
cc8089 |
This section exists to organize files related to @code{shell}
|
|
|
cc8089 |
functionality of @file{centos-art.sh} script.
|
|
|
cc8089 |
|
|
|
cc8089 |
@subsection Description
|
|
|
cc8089 |
|
|
|
cc8089 |
The @code{shell} functionality of @file{centos-art.sh} script helps
|
|
|
cc8089 |
you to maintain bash scripts inside repository. For example, suppose
|
|
|
cc8089 |
you've created many functionalities for @file{centos-art.sh} script,
|
|
|
cc8089 |
and you want to use a common copyright and license note for
|
|
|
cc8089 |
consistency in all your script files. If you have a bunch of files,
|
|
|
cc8089 |
doing this one by one wouldn't be a big deal. In contrast, if the
|
|
|
cc8089 |
amount of files grows, updating the copyright and license note for all
|
|
|
cc8089 |
of them would be a task rather tedious. The @code{shell} functionality
|
|
|
cc8089 |
exists to solve maintainance tasks just as the one previously
|
|
|
cc8089 |
mentioned.
|
|
|
cc8089 |
|
|
|
cc8089 |
When you use @code{shell} functionality to update copyright inside
|
|
|
cc8089 |
script files, it is required that your script files contain (at least)
|
|
|
cc8089 |
the following top commentary structure:
|
|
|
cc8089 |
|
|
|
cc8089 |
@float Figure,fig:trunk/Scripts/Bash/Functions/Shell:1
|
|
|
cc8089 |
@verbatim
|
|
|
cc8089 |
1| #!/bin/bash
|
|
|
cc8089 |
2| #
|
|
|
cc8089 |
3| # doSomething.sh -- The function description goes here.
|
|
|
cc8089 |
4| #
|
|
|
cc8089 |
5| # Copyright
|
|
|
cc8089 |
6| #
|
|
|
cc8089 |
7| # ...
|
|
|
cc8089 |
8| #
|
|
|
cc8089 |
9| # ----------------------------------------------------------------------
|
|
|
cc8089 |
10| # $Id$
|
|
|
cc8089 |
11| # ----------------------------------------------------------------------
|
|
|
cc8089 |
12|
|
|
|
cc8089 |
13| function doSomething {
|
|
|
cc8089 |
14|
|
|
|
cc8089 |
15| }
|
|
|
cc8089 |
@end verbatim
|
|
|
cc8089 |
@caption{The functions script base comment structure}
|
|
|
cc8089 |
@end float
|
|
|
cc8089 |
|
|
|
cc8089 |
Relevant lines in the above structure are lines from 5 to 9.
|
|
|
cc8089 |
Everything else in the file is left immutable.
|
|
|
cc8089 |
|
|
|
cc8089 |
When you are updating copyright through @code{shell}
|
|
|
cc8089 |
functionality, the @file{centos-art.sh} script replaces everything
|
|
|
cc8089 |
in-between line 5 ---the first one matching @samp{^# Copyright .+$}
|
|
|
cc8089 |
string--- and line 9---the first long dash separator matching @samp{^#
|
|
|
cc8089 |
-+$}--- with the content of copyright template instance.
|
|
|
cc8089 |
|
|
|
cc8089 |
@quotation
|
|
|
cc8089 |
@strong{Caution} Be sure to add the long dash separator that matches
|
|
|
cc8089 |
@samp{^# -+$} regular expression @emph{before} the function
|
|
|
cc8089 |
definition. Otherwise, if the @samp{Copyright} line is present but no
|
|
|
cc8089 |
long dash separator exists, @file{centos-art.sh} will remove anything
|
|
|
cc8089 |
in-between the @samp{Copyright} line and the end of file. This way you
|
|
|
cc8089 |
may lost your function definitions entirely.
|
|
|
cc8089 |
@end quotation
|
|
|
cc8089 |
|
|
|
cc8089 |
The copyright template instance is created from one copyright template
|
|
|
cc8089 |
stored in the @file{Config/tpl_forCopyright.sed} file. The template
|
|
|
cc8089 |
instance is created once, and later removed when no longer needed. At
|
|
|
cc8089 |
this moment, when template instance is created, the
|
|
|
cc8089 |
@file{centos-art.sh} script takes advantage of automation in order to
|
|
|
cc8089 |
set copyright full name and date dynamically.
|
|
|
cc8089 |
|
|
|
cc8089 |
When you use @code{shell} functionality to update copyright, the first
|
|
|
cc8089 |
thing @file{shell} functionality does is requesting copyright
|
|
|
cc8089 |
information to user, and later, if values were left empty (i.e., no
|
|
|
cc8089 |
value was typed before pressing @key{RET} key), the @file{shell}
|
|
|
cc8089 |
functionality uses its own default values.
|
|
|
cc8089 |
|
|
|
cc8089 |
When @code{shell} functionality uses its own default values, the final
|
|
|
cc8089 |
copyright note looks like the following:
|
|
|
cc8089 |
|
|
|
cc8089 |
@float Figure,fig:trunk/Scripts/Bash/Functions/Shell:2
|
|
|
cc8089 |
@verbatim
|
|
|
cc8089 |
1| #!/bin/bash
|
|
|
cc8089 |
2| #
|
|
|
cc8089 |
3| # doSomthing.sh -- The function description goes here.
|
|
|
cc8089 |
4| #
|
|
|
cc8089 |
5| # Copyright (C) 2003, 2010 The CentOS Project
|
|
|
cc8089 |
6| #
|
|
|
cc8089 |
7| # This program is free software; you can redistribute it and/or modify
|
|
|
cc8089 |
8| # it under the terms of the GNU General Public License as published by
|
|
|
cc8089 |
9| # the Free Software Foundation; either version 2 of the License, or
|
|
|
cc8089 |
10| # (at your option) any later version.
|
|
|
cc8089 |
11| #
|
|
|
cc8089 |
12| # This program is distributed in the hope that it will be useful, but
|
|
|
cc8089 |
13| # WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
cc8089 |
14| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
cc8089 |
15| # General Public License for more details.
|
|
|
cc8089 |
16| #
|
|
|
cc8089 |
17| # You should have received a copy of the GNU General Public License
|
|
|
cc8089 |
18| # along with this program; if not, write to the Free Software
|
|
|
cc8089 |
19| # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
cc8089 |
20| # USA.
|
|
|
cc8089 |
21| #
|
|
|
cc8089 |
22| # ----------------------------------------------------------------------
|
|
|
cc8089 |
23| # $Id$
|
|
|
cc8089 |
24| # ----------------------------------------------------------------------
|
|
|
cc8089 |
25|
|
|
|
cc8089 |
26| function doSomething {
|
|
|
cc8089 |
27|
|
|
|
cc8089 |
28| }
|
|
|
cc8089 |
@end verbatim
|
|
|
cc8089 |
@caption{The function script comment example}
|
|
|
cc8089 |
@end float
|
|
|
cc8089 |
|
|
|
cc8089 |
Relevant lines in the above structure are lines from 5 to 22. Pay
|
|
|
cc8089 |
attention how the copyright line was built, and how the license was
|
|
|
cc8089 |
added into the top comment where previously was just three dots.
|
|
|
cc8089 |
Everything else in the file was left immutable.
|
|
|
cc8089 |
|
|
|
cc8089 |
To change copyright information (i.e., full name or year information),
|
|
|
cc8089 |
run the @code{shell} functionality over the root directory containing
|
|
|
cc8089 |
the script files you want to update copyright in and enter the
|
|
|
cc8089 |
appropriate information when it be requested. You can run the
|
|
|
cc8089 |
@code{shell} functionality as many times as you need to.
|
|
|
cc8089 |
|
|
|
cc8089 |
To change copyright license (i.e., the text in-between lines 7 and
|
|
|
cc8089 |
20), you need to edit the @file{Config/tpl_forCopyright.sed} file, set
|
|
|
cc8089 |
the appropriate information, and run the @code{shell} functionality
|
|
|
cc8089 |
once again for changes to take effect over the files you specify.
|
|
|
cc8089 |
|
|
|
cc8089 |
@quotation
|
|
|
cc8089 |
@strong{Important} The @file{centos-art.sh} script is released as:
|
|
|
cc8089 |
|
|
|
cc8089 |
@verbatim
|
|
|
cc8089 |
GNU GENERAL PUBLIC LICENSE
|
|
|
cc8089 |
Version 2, June 1991
|
|
|
cc8089 |
|
|
|
cc8089 |
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
|
|
cc8089 |
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
cc8089 |
@end verbatim
|
|
|
cc8089 |
|
|
|
cc8089 |
Do not change the license information under which @file{centos-art.sh}
|
|
|
cc8089 |
script is released. Instead, if you think a different license must be
|
|
|
cc8089 |
used, please share your reasons at @email{centos-devel@@centos-art.sh,
|
|
|
cc8089 |
CentOS Developers mailing list}.
|
|
|
cc8089 |
@end quotation
|
|
|
cc8089 |
|
|
|
cc8089 |
@subsection Usage
|
|
|
cc8089 |
|
|
|
cc8089 |
@table @command
|
|
|
cc8089 |
@item centos-art sh --update-copyright='path/to/dir'
|
|
|
cc8089 |
@itemx centos-art sh --update-copyright='path/to/dir' --filter='regex'
|
|
|
cc8089 |
Use these commands to update copyright information in @samp{.sh} files
|
|
|
cc8089 |
under @samp{path/to/dir} directory.
|
|
|
cc8089 |
@end table
|
|
|
cc8089 |
|
|
|
cc8089 |
When you provide @option{--filter='regex'} argument, the list of files
|
|
|
cc8089 |
to process is reduced as specified in @samp{regex} regular expression.
|
|
|
cc8089 |
Inside @file{centos-art.sh} script, the @samp{regex} regular
|
|
|
cc8089 |
expression is used in combination with @command{find} command to look
|
|
|
cc8089 |
for files matching the regular expression path pattern.
|
|
|
cc8089 |
|
|
|
cc8089 |
@quotation
|
|
|
cc8089 |
@strong{Warning} In order for @samp{regex} regular expression to match
|
|
|
cc8089 |
a file, the @samp{regex} regular expresion must match the whole file
|
|
|
cc8089 |
path not just the file name.
|
|
|
cc8089 |
@end quotation
|
|
|
cc8089 |
|
|
|
cc8089 |
For example, if you want to match all @file{render.conf.sh} files
|
|
|
cc8089 |
inside @file{path/to/dir}, use the @code{.+/render.conf} regular
|
|
|
cc8089 |
expression. Later, @file{centos-art.sh} script uses this value inside
|
|
|
cc8089 |
@code{^$REGEX\.sh$} expression in order to build the final regular
|
|
|
cc8089 |
expression (i.e., @code{^.+/render.conf\.sh$}) that is evaluated
|
|
|
cc8089 |
against available file paths inside the list of files to process.
|
|
|
cc8089 |
|
|
|
cc8089 |
Exceptionally, when you provide @option{--filter='regex'} in the way
|
|
|
cc8089 |
that @samp{regex}, appended to @samp{path/to/dir/} (i.e.
|
|
|
cc8089 |
@samp{path/to/dir/regex}), matches a regular file; the
|
|
|
cc8089 |
@file{centos-art.sh} script uses the file matching as only file in the
|
|
|
cc8089 |
list of files to process.
|
|
|
cc8089 |
|
|
|
cc8089 |
@subsection See also
|
|
|
cc8089 |
|
|
|
cc8089 |
@menu
|
|
|
cc8089 |
* trunk Scripts Bash::
|
|
|
65cd8a |
@comment --- Removed(* trunk Scripts Bash Functions::) ---
|
|
|
cc8089 |
@end menu
|