From fec56cdee671d9e76d939645754eda9016c53d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 27 Feb 2023 11:40:35 +0100 Subject: [PATCH] Replace awk by grep to check hostname:port --- dell/start-virtual-console.bash | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/dell/start-virtual-console.bash b/dell/start-virtual-console.bash index 409757a..c48facf 100755 --- a/dell/start-virtual-console.bash +++ b/dell/start-virtual-console.bash @@ -147,13 +147,9 @@ define_vars() { # {{{ error_message "iDrac host can't be empty, please check your input or use --host option. For more informations, see the help message (--help)." 11 fi ## }}} - ## If idrac_host_temp is still empty {{{ - if [ -z "${idrac_host_temp-}" ]; then - error_message "iDrac host can't be empty, please check your input or use --host option. For more informations, see the help message (--help)." 11 - fi - ## }}} ## If idrac_host_temp contains a port number {{{ - if printf '%b' "${idrac_host_temp}" | awk 'BEGIN { FS = ":" } ; /^[a-zA-Z]+.*:[0-9]+$/' >/dev/null; then + if printf '%b' "${idrac_host_temp}" | grep --extended-regexp '^[a-zA-Z]+.*:[0-9]+$' >/dev/null; then + debug_message "- Try to extract hostname and port number from value (${RED}${idrac_host_temp}${COLOR_DEBUG})." ### Extract hostname and port number idrac_host=$(printf '%b' "${idrac_host_temp}" | awk 'BEGIN { FS = ":" } ; /^[a-zA-Z]+.*:[0-9]+$/ { print $1 }') idrac_port=$(printf '%b' "${idrac_host_temp}" | awk 'BEGIN { FS = ":" } ; /^[a-zA-Z]+.*:[0-9]+$/ { print $2 }') @@ -290,8 +286,9 @@ main() { # {{{ ## }}} ## Define all vars + debug_message "| Define vars BEGIN" define_vars - debug_message "| Define vars" + debug_message "| Define vars END" debug_message "| Given informations are : idrac_host: ${RED}${idrac_host}${COLOR_DEBUG}