From 9e013bcab706e06ddd204cddc5f4cb7d9484ee54 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Tue, 28 Oct 2008 01:27:14 +0000 Subject: [PATCH] Fixed version number display to handle that part dynamically, fixed more code --- inxi | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/inxi b/inxi index 116d1a4..dae1c7e 100755 --- a/inxi +++ b/inxi @@ -50,9 +50,11 @@ shopt -u nullglob #### UNCALCULATED VARIABLES ######################################################################## -SELF="inxi" -SELF_LC=$(echo "$SELF" | tr '[A-Z]' '[a-z]') -MYVERSION="$SELF 0.1.0" +SCRIPT_NAME="inxi" +SCRIPT_LOWER_CASE=$( tr '[A-Z]' '[a-z]' <<< $SCRIPT_NAME ) +SCRIPT_PATH=$( dirname $0 ) +SCRIPT_VERSION_NUMBER=$( grep -m 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | awk '{print $3}' ) +MY_VERSION="$SCRIPT_NAME $SCRIPT_VERSION_NUMBER" LC_ALL="C" # Make sure every program speaks English. export LC_ALL OIFS="$IFS" # Backup the current Internal Field Seperator @@ -93,11 +95,19 @@ XPATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" # Extra pat PARAMLIMIT=30 # This is a variable that controls how many parameters infobash will parse in a /proc//cmdline file before stopping. CRAP=0 # New parameter FLAG=0 # A throw-away 'flag' variable intended to be used throughout infobash -KONVICFG="konversation/scripts/$SELF_LC.conf" # relative path to $(kde-config --path data) +KONVICFG="konversation/scripts/$SCRIPT_LOWER_CASE.conf" # relative path to $(kde-config --path data) DCOPOBJ="default" -[[ -s /etc/$SELF_LC.conf ]] && source /etc/$SELF_LC.conf # Source global config overrides -[[ -s $HOME/.$SELF_LC ]] && source $HOME/.$SELF_LC # Source user config overrides +# Source global config overrides +if [[ -s /etc/$SCRIPT_LOWER_CASE.conf ]] +then + source /etc/$SCRIPT_LOWER_CASE.conf +fi +# Source user config overrides +if [[ -s $HOME/.$SCRIPT_LOWER_CASE ]] +then + source $HOME/.$SCRIPT_LOWER_CASE +fi # WARNING: In the main part below (search for 'KONVI') # there's a check for Konversation-specific config files. # Any one of these can override the above if infobash is run @@ -133,22 +143,22 @@ error() { case $1 in 2) - say "$SELF: large flood danger, debug buffer full!" + say "$SCRIPT_NAME: large flood danger, debug buffer full!" ;; 3) - say "$SELF: error in colorscheme, or unknown parameter: $2" + say "$SCRIPT_NAME: error in colorscheme, or unknown parameter: $2" ;; 4) - say "$SELF: unknown verbosity level $2" + say "$SCRIPT_NAME: unknown verbosity level $2" ;; 5) - say "$SELF: dependency not met: $2 not found in path" + say "$SCRIPT_NAME: dependency not met: $2 not found in path" ;; 6) - say "$SELF: /proc not found! Quitting..." + say "$SCRIPT_NAME: /proc not found! Quitting..." ;; *) - say "$SELF: error unknown: $@" + say "$SCRIPT_NAME: error unknown: $@" set -- 99 ;; esac @@ -1047,7 +1057,7 @@ then then LNLAST="${LNLAST}$(echo -ne " | ${C1}Client${C2} ${IRC}${IRCV}${CN}")" fi - LNLAST="${LNLAST}$(echo -ne " | ${C1}${MYVERSION}")" + LNLAST="${LNLAST}$(echo -ne " | ${C1}${MY_VERSION}")" if ((SCHEME)) then LNLAST="${LNLAST}$(echo -ne "${NORMAL}")"