Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Seitosh
Seitosh
Commits
a3a85181
Commit
a3a85181
authored
Jul 24, 2020
by
thomas.forbriger
Browse files
utilities/news [FEATURE]: provide extended bash body
parent
77ca6120
Changes
1
Hide whitespace changes
Inline
Side-by-side
contrib/utilities/new
View file @
a3a85181
...
...
@@ -44,10 +44,11 @@
# 29/01/2015 V1.17 do not use subversion Id keyword - operate in git
# 04/10/2015 V1.18 add type stxt
# 26/10/2015 V1.19 add type bash
# 24/07/2020 V1.20 provide extended bash body
#
# ============================================================================
#
NEW_VERSION
=
"NEW V1.
19
all purpose bodyguard"
NEW_VERSION
=
"NEW V1.
20
all purpose bodyguard"
tmpfile
=
/tmp/new
$$
.tmp
...
...
@@ -176,6 +177,93 @@ HERE
# END OF generic_shell_header()
#
# ----------------------------------------------------------------------------
bash_body
()
{
NONE
=
""
BASENAME
=
$(
basename
$1
.sh
)
UPPERNAME
=
$(
str_upper
$BASENAME
)
/bin/cat
>>
$tmpfile
<<
NEWHERE
#
VERSION=
$(
date
+
'%Y-%m-%d'
)
#
# ============================================================================
# '**** define usage functions ****'
# ============================================================================
#
usage() {
cat >&2 << HERE
$UPPERNAME
V
\$
VERSION
$2
usage:
$1
[--verbose|-v]
or:
$1
--help|-h
HERE
}
#
# ----------------------------------------------------------------------------
#
longusage() {
cat >&2 <<HERE
-v|--verbose be verbose
-D|--debug produce debugging output
HERE
}
#
# ============================================================================
# **** define action functions ****
# ============================================================================
#
#
# ============================================================================
# **** the main part of the shell script starts here ****
# ============================================================================
#
# ----
# read command line options
# -------------------------
TEMP=
\$
(getopt -o vDh --long help,verbose,debug
\
-n
\$
(basename
\$
0) -- "
\$
@") || {
echo >&2
echo >&2 "ERROR: command line parameters are incorrect!"
echo >&2 "aborting
\$
0..."; exit 2
}
eval set -- "
\$
TEMP"
# ----
#
# ============================================================================
# output starts here
# ------------------
#
# print usage if no command line parameter is present
if test
\$
# -le 1
then
usage
exit
fi
#
# extract command line options
# ----------------------------
VERBOSE=0
while true; do
case "
\$
1" in
--help|-h) usage; echo; longusage; exit 1;;
--) shift; break;;
-v|--verbose) VERBOSE=1;;
-D|--debug) set -x ;;
*) echo >&2 "ERROR: option
\$
1 unprocessed!";
echo >&2 "aborting
\$
0..."; exit 2;;
esac
shift
done
#
# ----------------------------------------------------------------------------
# run
#
NEWHERE
}
#
# END OF bash_body()
#
# ----------------------------------------------------------------------------
f_header
()
{
...
...
@@ -802,6 +890,7 @@ create_sh()
create_bak
$FILENAME
generic_shell_header
$FILENAME
"
$PURPOSE
"
'#!/bin/sh'
bash_body
$FILENAME
"
$PURPOSE
"
catch_old
$FILENAME
generic_shell_closing
$FILENAME
fetch_tmp
$FILENAME
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment