Define vars in a function

This commit is contained in:
Jeremy Gardais 2020-06-24 14:14:08 +02:00
parent cc1ccba855
commit 3d6d8de497
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 21 additions and 7 deletions

View File

@ -51,6 +51,25 @@ debug_message() { # {{{
## Print message if DEBUG is enable (=0) ## Print message if DEBUG is enable (=0)
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6b\e[m\n' "DEBUG ${PROGNAME}: ${local_debug_message}" [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6b\e[m\n' "DEBUG ${PROGNAME}: ${local_debug_message}"
}
# }}}
define_vars() { # {{{
## If sge_hostname wasn't defined
if [ -z "${sge_hostname}" ]; then
## Use local host for sge_hostname
sge_hostname="$(hostname -f)"
fi
## Get all queues name
sge_queues_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \
| grep "queue name" \
| cut -d"'" -f2 )"
sge_queues_name_print="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \
| grep "queue name" \
| cut -d"'" -f2 \
| tr -s '\n' ' ' )"
} }
# }}} # }}}
is_queue_enable() { # {{{ is_queue_enable() { # {{{
@ -162,13 +181,8 @@ Try to disable SGE queue: ${RED}${local_sge_queue_name:=/dev/null}@${local_sge_h
# }}} # }}}
main() { # {{{ main() { # {{{
sge_queues_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \ ## Define all vars according the selected options
| grep "queue name" \ define_vars
| cut -d"'" -f2 )"
sge_queues_name_print="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \
| grep "queue name" \
| cut -d"'" -f2 \
| tr -s '\n' ' ' )"
## Simple debug message with color to valid current variables ## Simple debug message with color to valid current variables
debug_message "main Try to manage \ debug_message "main Try to manage \