From dbaa50c025dbfc3d8574e57ddbfa8e4cbf1b89d5 Mon Sep 17 00:00:00 2001 From: Dalibor Pospisil Date: Sun, 28 Apr 2019 21:02:59 +0200 Subject: [PATCH 2/2] do not suppress getopt error getopt was often used with -q option now the stderr output is processed and logged as an error message --- src/infrastructure.sh | 12 ++++++------ src/logging.sh | 2 +- src/storage.sh | 2 +- src/synchronisation.sh | 8 ++++---- src/testing.sh | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/infrastructure.sh b/src/infrastructure.sh index 4c76736..1c97205 100644 --- a/src/infrastructure.sh +++ b/src/infrastructure.sh @@ -219,7 +219,7 @@ Returns 0 if mounting the share was successful. rlMount() { local OPTIONS='' - local GETOPT=$(getopt -q -o o: -- "$@"); eval set -- "$GETOPT" + local GETOPT=$(getopt -o o: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" while true; do case $1 in --) shift; break; ;; @@ -288,7 +288,7 @@ options, 2 otherwise. rlCheckMount() { local MNTOPTS='' - local GETOPT=$(getopt -q -o o: -- "$@"); eval set -- "$GETOPT" + local GETOPT=$(getopt -o o: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" while true; do case $1 in --) shift; break; ;; @@ -383,7 +383,7 @@ the mountpoint uses all the given options. rlAssertMount() { local MNTOPTS='' - local GETOPT=$(getopt -q -o o: -- "$@"); eval set -- "$GETOPT" + local GETOPT=$(getopt -o o: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" while true; do case $1 in --) shift; break; ;; @@ -461,7 +461,7 @@ Returns 0 if success. =cut rlHash() { - local GETOPT=$(getopt -q -o a: -l decode,algorithm:,stdin -- "$@"); eval set -- "$GETOPT" + local GETOPT=$(getopt -o a: -l decode,algorithm:,stdin -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" local decode=0 alg="$rlHashAlgorithm" stdin=0 while true; do case $1 in @@ -637,7 +637,7 @@ rlFileBackup() { local IFS # getopt will cut off first long opt when no short are defined - OPTS=$(getopt -o "." -l "clean,namespace:,no-missing-ok,missing-ok" -- "$@") + OPTS=$(getopt -o "." -l "clean,namespace:,no-missing-ok,missing-ok" -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) [ $? -ne 0 ] && return 1 eval set -- "$OPTS" @@ -813,7 +813,7 @@ rlFileRestore() { local IFS # getopt will cut off first long opt when no short are defined - OPTS=$(getopt -o "n:" -l "namespace:" -- "$@") + OPTS=$(getopt -o "n:" -l "namespace:" -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) [ $? -ne 0 ] && return 1 eval set -- "$OPTS" diff --git a/src/logging.sh b/src/logging.sh index e49dcb4..79df02b 100644 --- a/src/logging.sh +++ b/src/logging.sh @@ -487,7 +487,7 @@ rlFileSubmit -s '_' /etc/passwd -> etc_passwd =cut rlFileSubmit() { - GETOPT=$(getopt -q -o s: -- "$@") + GETOPT=$(getopt -o s: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) eval set -- "$GETOPT" SEPARATOR='-' diff --git a/src/storage.sh b/src/storage.sh index b3f7636..a1b4ae3 100644 --- a/src/storage.sh +++ b/src/storage.sh @@ -46,7 +46,7 @@ __INTERNAL_STORAGE_DEFAULT_NAMESPACE="GENERIC" __INTERNAL_ST_OPTION_PARSER=' local namespace="$__INTERNAL_STORAGE_DEFAULT_NAMESPACE" local section="$__INTERNAL_STORAGE_DEFAULT_SECTION" - local GETOPT=$(getopt -o : -l namespace:,section: -- "$@") || return 126 + local GETOPT=$(getopt -o : -l namespace:,section: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) || return 126 eval set -- "$GETOPT" while true; do case $1 in diff --git a/src/synchronisation.sh b/src/synchronisation.sh index 3c7c275..dcff59d 100644 --- a/src/synchronisation.sh +++ b/src/synchronisation.sh @@ -118,7 +118,7 @@ __INTERNAL_wait_for_cmd() { shift 1 # that is the GNU extended getopt syntax! - local TEMP=$(getopt -o t:p:m:d:r: -n '$routine_name' -- "$@") + local TEMP=$(getopt -o t:p:m:d:r: -n '$routine_name' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) if [[ $? != 0 ]] ; then rlLogError "$routine_name: Can't parse command options, terminating..." return 127 @@ -345,7 +345,7 @@ rlWaitForFile() { local file="" # that is the GNU extended getopt syntax! - local TEMP=$(getopt -o t:p:d: -n 'rlWaitForFile' -- "$@") + local TEMP=$(getopt -o t:p:d: -n 'rlWaitForFile' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) if [[ $? != 0 ]] ; then rlLogError "rlWaitForSocket: Can't parse command options, terminating..." return 127 @@ -436,7 +436,7 @@ rlWaitForSocket(){ local field="5" # that is the GNU extended getopt syntax! - local TEMP=$(getopt -o t:p:d: --longoptions close,remote -n 'rlWaitForSocket' -- "$@") + local TEMP=$(getopt -o t:p:d: --longoptions close,remote -n 'rlWaitForSocket' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) if [[ $? != 0 ]] ; then rlLogError "rlWaitForSocket: Can't parse command options, terminating..." return 127 @@ -530,7 +530,7 @@ Signal used to kill the process, optional SIGTERM by default. rlWait() { # that is the GNU extended getopt syntax! - local TEMP=$(getopt -o t:s: -n 'rlWait' -- "$@") + local TEMP=$(getopt -o t:s: -n 'rlWait' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) if [[ $? != 0 ]]; then rlLogError "rlWait: Can't parse command options, terminating..." return 128 diff --git a/src/testing.sh b/src/testing.sh index e97bd01..eceb402 100644 --- a/src/testing.sh +++ b/src/testing.sh @@ -717,7 +717,7 @@ explain what are you doing here). Returns the exit code of the command run. Asserts PASS when command\'s exit status is in the list of expected exit codes. -Note: +Note: =over @@ -754,7 +754,7 @@ B using C tool is now disabled because of bug 547686. #' rlRun() { - local __INTERNAL_rlRun_GETOPT=$(getopt -q -o lcts -- "$@") + local __INTERNAL_rlRun_GETOPT=$(getopt -o lcts -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) eval set -- "$__INTERNAL_rlRun_GETOPT" local __INTERNAL_rlRun_DO_LOG=false @@ -1194,7 +1194,7 @@ __INTERNAL_rlIsDistro(){ local whole="$(beakerlib-lsb_release -rs)" local major="$(beakerlib-lsb_release -rs | cut -d '.' -f 1)" local IFS - + rlLogDebug "distro='$distro'" rlLogDebug "major='$major'" rlLogDebug "whole='$whole'" -- 2.17.2