summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2017-02-03 09:27:19 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2017-02-03 13:05:39 +0000
commit7dc65c4426b7175b54ab472d57e62d68df8b574e (patch)
treef881eca5c3170e6e57f5abdc791960709d350b95
parent613506f7e315d3a9f05413e729dfb3f0dbf812b8 (diff)
nodename2hostname.sh: Make sure all error messages go to stderr.
Change-Id: I56eac26f9537e1282a04ae31b2e49c214335762c
-rwxr-xr-xnodename2hostname.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/nodename2hostname.sh b/nodename2hostname.sh
index 22a33441..41dd2dd3 100755
--- a/nodename2hostname.sh
+++ b/nodename2hostname.sh
@@ -9,6 +9,12 @@
# FIXME: try to get rid of this script, it's going to be a maintenance
# nightmare :-)
+# Save stdout/stderr file descriptors
+exec 3>&1 4>&2
+
+# Make sure all output goes to stderr
+exec 1>&2
+
NODE=$1
if [ x"$NODE" = x ]; then
echo "Usage: $0 node-name"
@@ -31,10 +37,13 @@ case ${NODE} in
NAME=dev-${ID}
;;
*)
- echo "Error: unsupported NODE value: ${NODE}" 1>&2
+ echo "Error: unsupported NODE value: ${NODE}"
exit 1
;;
esac
+# Restore stdout/stderr, so that expected output goes to stdout
+exec 1>&3 2>&4
+
echo ${NAME}
exit 0