From 62ce1bfe6779ce480c65cdfe7fc6303102dee0dc Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Tue, 21 Oct 2008 00:09:12 +0200 Subject: [PATCH] Use Msg() function to output console messages. The Msg() function abstracts diffenences in the echo(1) command and shell built-in functions. This implementation always calls /bin/echo ... --- install.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/install.sh b/install.sh index 1d2fba9..ad13c6b 100755 --- a/install.sh +++ b/install.sh @@ -6,36 +6,40 @@ NAME=`basename "$0"` +Msg() { + /bin/echo -e "$*" +} + Abort() { - echo "- ERROR!" + Msg "- ERROR!" exit 1 } Copy_File() { src="$1"; dst="$2"; own="$3"; perm="$4" - echo " $src -> $dst\c" + Msg " $src -> $dst\c" if [ -e "$dst" ]; then grep "alex@barton.de" "$dst" >/dev/null 2>&1 if [ $? -ne 0 ]; then - echo " (B)\c" + Msg " (B)\c" cp "$dst" "$dst.bak" fi fi - echo " \c" + Msg " \c" cp "$src" "$dst" || Abort [ -n "$own" ] && chown "$own" "$dst" || Abort [ -n "$perm" ] && chmod "$perm" "$dst" || Abort - echo "- OK." + Msg "- OK." } [ -n "$UID" ] || UID=`id -u` export UID -echo "Running $NAME (uid=$UID) ..." +Msg "Running $NAME (uid=$UID) ..." if [ "$UID" = "0" ]; then - echo "Starting system configuration:" - echo " - bash shell:" + Msg "Starting system configuration:" + Msg " - bash shell:" if [ -e /etc/bash.bashrc ]; then Copy_File sys/bashrc /etc/bash.bashrc root 644 else @@ -43,15 +47,15 @@ if [ "$UID" = "0" ]; then fi Copy_File sys/profile /etc/profile root 644 else - echo "Not running with root privileges - system configuration SKIPPED." + Msg "Not running with root privileges - system configuration SKIPPED." fi user=`basename "$HOME"` touch "$HOME/.test.$$" >/dev/null 2>&1 if [ $? -eq 0 ]; then rm -f "$HOME/.test.$$" - echo "Starting user configuration ($user in $HOME):" - echo " - bash shell:" + Msg "Starting user configuration ($user in $HOME):" + Msg " - bash shell:" if [ -e "$HOME/.profile" ]; then Copy_File user/bash_profile "$HOME/.profile" "$user" 600 else @@ -60,9 +64,9 @@ if [ $? -eq 0 ]; then Copy_File user/bashrc "$HOME/.bashrc" "$user" 600 Copy_File user/bash_logout "$HOME/.bash_logout" "$user" 600 else - echo "Can't write to user home directory - user configuration SKIPPED." + Msg "Can't write to user home directory - user configuration SKIPPED." fi -echo "$NAME: Done." +Msg "$NAME: Done." # -eof- -- 2.39.2