From 14039d9fe47933e27de016fc33c4e8d8122d0645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Mej=C3=ADas=20Rodr=C3=ADguez?= Date: Sun, 25 Nov 2018 13:09:06 -0500 Subject: [PATCH] Redirected error messages to stderr --- psu | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/psu b/psu index e3b8ca8..63222de 100755 --- a/psu +++ b/psu @@ -14,8 +14,8 @@ check_argument () { local argument_envvar=$3 local argument_flag=$4 if [ -z "$argument_value" ]; then - echo "Error: Missing argument \"$argument_name\"." - echo "Try setting \"$argument_envvar\" environment variable or using the \"-$argument_flag\" flag." + >&2 echo "Error: Missing argument \"$argument_name\"." + >&2 echo "Try setting \"$argument_envvar\" environment variable or using the \"-$argument_flag\" flag." exit 1 fi } @@ -31,12 +31,12 @@ check_for_errors () { local response=$2 if [ $exit_code -ne 0 ]; then case $exit_code in - 2) echo 'Request timed out!' ;; - 3) echo 'Unexpected HTTP 3xx Redirection!' ;; - 4) echo 'HTTP 4xx Client Error!' && echo $response ;; - 5) echo 'HTTP 5xx Server Error!' && echo $response ;; - 6) echo 'Exceeded --max-redirects= redirects!' ;; - *) echo 'Unholy Error!' ;; + 2) >&2 echo 'Request timed out!' ;; + 3) >&2 echo 'Unexpected HTTP 3xx Redirection!' ;; + 4) >&2 echo 'HTTP 4xx Client Error!' && echo $response ;; + 5) >&2 echo 'HTTP 5xx Server Error!' && echo $response ;; + 6) >&2 echo 'Exceeded --max-redirects= redirects!' ;; + *) >&2 echo 'Unholy Error!' ;; esac exit 1 fi @@ -155,7 +155,7 @@ deploy () { rm json.tmp else if [ $STRICT_MODE == "true" ]; then - echo "Error: Stack $PORTAINER_STACK_NAME already exists." + >&2 echo "Error: Stack $PORTAINER_STACK_NAME already exists." exit 1 fi echo_verbose "Stack $PORTAINER_STACK_NAME exists." @@ -192,7 +192,7 @@ deploy () { undeploy () { if [ -z "$STACK" ]; then if [ $STRICT_MODE == "true" ]; then - echo "Error: Stack $PORTAINER_STACK_NAME does not exist." + >&2 echo "Error: Stack $PORTAINER_STACK_NAME does not exist." exit 1 else echo_verbose "Stack $PORTAINER_STACK_NAME does not exist. No need to undeploy it." @@ -309,5 +309,5 @@ if [ $ACTION == "undeploy" ]; then exit 0 fi -echo "Error: Unknown action \"$ACTION\"." +>&2 echo "Error: Unknown action \"$ACTION\"." exit 1