Updated coding style
This commit is contained in:
parent
4ecdbfb0c0
commit
1fc8f9567e
|
@ -1,4 +1,5 @@
|
||||||
Coding style used for my bash projects (v3.0 Dec 2016)
|
Coding style used for my bash projects (v3.0 Dec 2016)
|
||||||
|
As bash is clearly an error prone script language, we'll use as much standard coding as possible, including some quick and dirty debug techniques described here.
|
||||||
|
|
||||||
++++++ Header
|
++++++ Header
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ __CheckArguments will only trigger when the script is launched with _PARANOIA_DE
|
||||||
Use the following convention for function definition:
|
Use the following convention for function definition:
|
||||||
|
|
||||||
function SomeFunction {
|
function SomeFunction {
|
||||||
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ Declare arguments before launching __CheckArguments:
|
||||||
function AnotherFunction {
|
function AnotherFunction {
|
||||||
local varName="${1}"
|
local varName="${1}"
|
||||||
local otherVarName="${2}" # This variable contains stuff
|
local otherVarName="${2}" # This variable contains stuff
|
||||||
__CheckArguments 2 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 2 $# "$@" #__WITH_PARANOIA_DEBUG
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ The basic way of doing is:
|
||||||
|
|
||||||
cmd='"something '$somevar'" > some_file 2>&1'
|
cmd='"something '$somevar'" > some_file 2>&1'
|
||||||
eval $cmd &
|
eval $cmd &
|
||||||
WaitForTaskCompletion $! 0 0 $FUNCNAME
|
WaitForTaskCompletion $! 0 0 1 0 true false true false
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -ne 0 ]; then
|
if [ $retval -ne 0 ]; then
|
||||||
Logger "Some error message" "ERROR" $retval
|
Logger "Some error message" "ERROR" $retval
|
||||||
|
|
Loading…
Reference in New Issue