]> arthur.barton.de Git - ConfigScripts.git/commitdiff
Use Msg() function to output console messages.
authorAlexander Barton <alex@barton.de>
Mon, 20 Oct 2008 22:09:12 +0000 (00:09 +0200)
committerAlexander Barton <alex@barton.de>
Mon, 20 Oct 2008 22:09:12 +0000 (00:09 +0200)
The Msg() function abstracts diffenences in the echo(1) command and
shell built-in functions. This implementation always calls /bin/echo ...

install.sh

index 1d2fba91c002fefe877a3cb5db07cffdce11eeb8..ad13c6b3afa8fa7aa11a2d19d200660f1ffd2db3 100755 (executable)
@@ -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-