From ff2e9e0f0169ec22b586954da607452ed0f823b0 Mon Sep 17 00:00:00 2001 From: Tony Duckles Date: Wed, 2 Nov 2011 20:01:54 -0500 Subject: [PATCH] .bashrc: MOTD tweaks --- .bashrc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.bashrc b/.bashrc index d1576be..fee04fc 100644 --- a/.bashrc +++ b/.bashrc @@ -383,12 +383,17 @@ test -n "$PS1" && # ------------------------------------------------------------------- test -n "$INTERACTIVE" -a -n "$LOGIN" && { - echo " --" - # Strip any leading whitespace from uname and uptime commands, - # and add a leading padding whitespace - echo -n " " && echo `uname -npsr | sed -e 's/^\s+//'` - echo -n " " && echo `uptime | sed -e 's/^\s+//'` - echo " --" + # Get current uname and uptime (if exists on this host) + # Strip any leading whitespace from uname and uptime commands + t_uname="$(test -n "`type -P uname`" && uname -npsr | sed -e 's/^\s+//')" + t_uptime="$(test -n "`type -P uptime`" && uptime | sed -e 's/^\s+//')" + if [ -n "$t_uname" ] || [ -n "$t_uptime" ]; then + echo " --" + test -n "$t_uname" && echo $t_uname + test -n "$t_uptime" && echo $t_uptime + echo " --" + fi + unset t_uname t_uptime } # vim: ts=4 sts=4 shiftwidth=4 expandtab -- 2.43.0