more refactoring

This commit is contained in:
inxi-svn 2008-10-29 03:03:18 +00:00
parent 05ad16866c
commit 6d63e5686b

50
inxi
View file

@ -10,7 +10,8 @@
#### inxi, the universal, portable, system info script for irc.
#### Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII,
#### Gaim/Pidgin, Weechat, KVIrc and Kopete.
#### Copyright (C) 2005-2007 locsmif <infobash@rebelhomicide.demon.nl>
#### Original infobash author and copyright holder:
#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif <infobash@rebelhomicide.demon.nl>
####
#### This program is free software; you can redistribute it and/or modify
#### it under the terms of the GNU General Public License as published by
@ -74,10 +75,6 @@ OIFS="$IFS" # Backup the current Internal Field Seperator
FL1='-' # These two determine separators in single line output, to force irc clients not to break off sections
FL2=''
## Variable initializations: script parameter/option globals
## Script names/paths
SCRIPT_NAME="inxi"
SCRIPT_PATH=$( dirname $0 )
@ -120,7 +117,7 @@ NORMAL_BANS=( corporation communications technologies technology group $'\2'"\<l
CPU_BANS=( cpu processor $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" )
EXTRA_PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" # Extra path variable to make execute failures less likely, merged below
KONVI_CFG="konversation/scripts/$SCRIPT_NAME.conf" # relative path to $(kde-config --path data)
# Source global config overrides
@ -179,9 +176,9 @@ error_handler()
script_debugger()
{
if (( ALLUP ))
if [ "$ALLUP" -gt 0 ]
then
if ! (( DEBUG ))
if [ "$DEBUG" -eq 0 ]
then
return
fi
@ -195,7 +192,7 @@ script_debugger()
fi
print_screen_output "$@"
else
if ((!DEBUG_FLOOD && DBI>10))
if ((!DEBUG_FLOOD && DBI > 10))
then
error_handler 2
fi
@ -316,7 +313,7 @@ make_bans()
# $1 = <scheme number>|<"none">
set_color_scheme()
{
local i='' scriptColors='' colorCodes=''
local i='' script_colors='' color_codes=''
if [[ $1 -ge ${#COLOR_SCHEMES[@]} ]]
then
@ -325,20 +322,20 @@ set_color_scheme()
SCHEME="$1" # Set a global variable to allow checking for chosen scheme later
if ((IBSHELL))
then
colorCodes=($ANSI_COLORS)
color_codes=($ANSI_COLORS)
else
colorCodes=($IRC_COLORS)
color_codes=($IRC_COLORS)
fi
for (( i=0; i < ${#COLORS_AVAILABLE[@]}; i++ ))
do
eval "${COLORS_AVAILABLE[i]}=\"${colorCodes[i]}\""
eval "${COLORS_AVAILABLE[i]}=\"${color_codes[i]}\""
done
IFS=","
scriptColors=(${COLOR_SCHEMES[$1]})
script_colors=(${COLOR_SCHEMES[$1]})
IFS="$OIFS"
C1="${!scriptColors[0]}"
C2="${!scriptColors[1]}"
CN="${!scriptColors[2]}"
C1="${!script_colors[0]}"
C2="${!script_colors[1]}"
CN="${!script_colors[2]}"
((CSCHEME++))
}
@ -584,34 +581,35 @@ get_start_source()
set_calculated_variables()
{
local i='' j=''
local path='' sys_path='' added_path=''
# Extra path variable to make execute failures less likely, merged below
local extra_paths="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
# Detect X and set variable "X" accordingly
if [[ $DISPLAY ]]
if [ -n "$DISPLAY" ]
then
X=1
fi
# Fallback paths put into $EXTRA_PATH; This might, among others, help on gentoo.
# Now, create a difference of $PATH and $EXTRA_PATH and add that to $PATH:
unset TPATH
IFS=":"
for i in $EXTRA_PATH
for path in $extra_paths
do
FLAG=0
for j in $PATH
for sys_path in $PATH
do
if [[ $i = $j ]]
if [ "$path" == "$sys_path" ]
then
FLAG=1
fi
done
if ! ((FLAG))
if [ "$FLAG" -eq 0 ]
then
TPATH="$TPATH:$i"
added_path="$added_path:$path"
fi
done
IFS="$OIFS"
PATH="${PATH}${TPATH}"
PATH="${PATH}${added_path}"
##echo "PATH='$PATH'"
##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""'