defensive bash
This commit is contained in:
parent
27aa914069
commit
3664abd6e8
|
@ -33,8 +33,12 @@ Détail du script `alerts_switch` :
|
|||
|
||||
set -e
|
||||
|
||||
readonly PROGNAME=$(basename $0)
|
||||
readonly PROGDIR=$(readlink -m $(dirname $0))
|
||||
readonly ARGS="$@"
|
||||
|
||||
usage() {
|
||||
echo "alerts_switch action prefix"
|
||||
echo "$PROGNAME action prefix"
|
||||
}
|
||||
|
||||
disable_alerts () {
|
||||
|
@ -72,11 +76,11 @@ log_enable () {
|
|||
}
|
||||
|
||||
main () {
|
||||
readonly action=$1
|
||||
readonly prefix=$2
|
||||
local action=$1
|
||||
local prefix=$2
|
||||
|
||||
readonly file_path="/tmp/${prefix}_alerts"
|
||||
readonly log_file="/var/log/${prefix}_alerts.log"
|
||||
local file_path="/tmp/${prefix}_alerts"
|
||||
local log_file="/var/log/${prefix}_alerts.log"
|
||||
|
||||
case "$action" in
|
||||
enable)
|
||||
|
@ -97,7 +101,7 @@ main () {
|
|||
esac
|
||||
}
|
||||
|
||||
main "$@"
|
||||
main $ARGS
|
||||
~~~
|
||||
|
||||
## (Dés)activation des alertes
|
||||
|
|
Loading…
Reference in New Issue