Skip to content

Commit 0326345

Browse files
author
Sven Vogel
committed
add comments to the failed and get options block / rename vars in failed block / typo Fix to cloudtmplt.sh
1 parent 2e03536 commit 0326345

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

scripts/storage/secondary/createtmplt.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,22 @@ usage() {
2525
#set -x
2626
ulimit -c 0
2727

28+
# Usage: e.g. failed $? "this is an error"
2829
failed() {
29-
echo $2
30-
if [[ $1 -eq 0 ]]; then
30+
local returnval=$1
31+
local returnmsg=$2
32+
33+
# check for an message, if there is no one dont print anything
34+
if [[ -z $returnmsg ]]; then
35+
:
36+
else
37+
echo -e $returnmsg
38+
fi
39+
if [[ $returnval -eq 0 ]]; then
3140
return 0
3241
else
3342
echo "Installation failed"
34-
exit $1
43+
exit $returnval
3544
fi
3645
}
3746

@@ -95,6 +104,13 @@ tflag=
95104
nflag=
96105
fflag=
97106

107+
# check if first parameter is not a dash (-) then print the usage block
108+
if [[ ! $@ =~ ^\-.+ ]]; then
109+
usage
110+
exit 0
111+
fi
112+
113+
OPTERR=0
98114
while getopts 't:n:f:' OPTION
99115
do
100116
case $OPTION in

0 commit comments

Comments
 (0)