put all core features into function containers as first step to break this into logical components

This commit is contained in:
inxi-svn 2008-10-28 03:42:28 +00:00
parent c1a4fe88b4
commit 22f0026e2c

124
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.1.8 #### version: 0.1.10
#### Date: October 27 2008 #### Date: October 27 2008
######################################################################## ########################################################################
#### inxi is a fork of infobash, the original bash sys info script by locsmif #### inxi is a fork of infobash, the original bash sys info script by locsmif
@ -113,6 +113,10 @@ if [[ -s $HOME/.$SCRIPT_LOWER_CASE ]]
then then
source $HOME/.$SCRIPT_LOWER_CASE source $HOME/.$SCRIPT_LOWER_CASE
fi fi
ALLUP=1
HN=$(hostname)
# WARNING: In the main part below (search for 'KONVI') # WARNING: In the main part below (search for 'KONVI')
# there's a check for Konversation-specific config files. # there's a check for Konversation-specific config files.
# Any one of these can override the above if infobash is run # Any one of these can override the above if infobash is run
@ -319,7 +323,8 @@ get_start_app()
KONVI=1 KONVI=1
IRCV="$( $IRC -v | gawk '/Konversation:/ { for (i=2;i<=NF;i++) { if (i == NF) { print $i } else { printf $i" " } } exit }' )" IRCV="$( $IRC -v | gawk '/Konversation:/ { for (i=2;i<=NF;i++) { if (i == NF) { print $i } else { printf $i" " } } exit }' )"
T=($IRCV) T=($IRCV)
if [[ ${T[0]} == *+* ]]; then if [[ ${T[0]} == *+* ]]
then
# < Sho_> locsmif: The version numbers of SVN versions look like this: # < Sho_> locsmif: The version numbers of SVN versions look like this:
# "<version number of last release>+ #<build number", i.e. "1.0+ #3177" ... # "<version number of last release>+ #<build number", i.e. "1.0+ #3177" ...
# for releases we remove the + and build number, i.e. "1.0" or soon "1.0.1" # for releases we remove the + and build number, i.e. "1.0" or soon "1.0.1"
@ -494,22 +499,25 @@ sanitize()
echo "$2" | gawk "BEGIN { IGNORECASE=1 } { gsub(/${!1}/,\"\"); gsub(/ [ ]+/,\" \"); gsub(/^ +| +$/,\"\"); print }" echo "$2" | gawk "BEGIN { IGNORECASE=1 } { gsub(/${!1}/,\"\"); gsub(/ [ ]+/,\" \"); gsub(/^ +| +$/,\"\"); print }"
} }
######################################################################## ########################################################################
#### CALCULATED VARIABLES #### MAIN FUNCTIONS
######################################################################## ########################################################################
# Detect X and set variable "X" accordingly set_calculated_variables()
if [[ $DISPLAY ]] {
then # Detect X and set variable "X" accordingly
if [[ $DISPLAY ]]
then
X=1 X=1
fi fi
# Fallback paths put into $EXTRA_PATH; This might, among others, help on gentoo. # 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: # Now, create a difference of $PATH and $EXTRA_PATH and add that to $PATH:
unset TPATH unset TPATH
IFS=":" IFS=":"
for I in $EXTRA_PATH for I in $EXTRA_PATH
do do
FLAG=0 FLAG=0
for J in $PATH for J in $PATH
do do
@ -522,29 +530,24 @@ do
then then
TPATH="$TPATH:$I" TPATH="$TPATH:$I"
fi fi
done done
IFS="$OIFS" IFS="$OIFS"
PATH="${PATH}${TPATH}" PATH="${PATH}${TPATH}"
##echo "PATH='$PATH'" ##echo "PATH='$PATH'"
##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""' ##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""'
# Check for dependencies before running any commands in this script! So yes, here!! # Do this after sourcing of config overrides so user can customize banwords
check_script_depends NORMAL_BANS=$( make_bans "${NORMAL_BANS[@]}" ) # Contrary to my previous belief, "${ARR[@]}" passes a quoted list, not one string
CPU_BANS=$( make_bans "${CPU_BANS[@]}" )
##echo "NORMAL_BANS='$NORMAL_BANS'"
# Do this after sourcing of config overrides so user can customize banwords LSPCI=$(lspci -v | awk '{ gsub(/\(prog-if[^)]*\)/,""); print }')
NORMAL_BANS=$( make_bans "${NORMAL_BANS[@]}" ) # Contrary to my previous belief, "${ARR[@]}" passes a quoted list, not one string }
CPU_BANS=$( make_bans "${CPU_BANS[@]}" )
##echo "NORMAL_BANS='$NORMAL_BANS'"
LSPCI=$(lspci -v | awk '{ gsub(/\(prog-if[^)]*\)/,""); print }') set_konvi()
######################################################################## {
#### MAIN FUNCTIONS if ((KONVI))
######################################################################## then
get_start_app
if ((KONVI))
then
DCPORT="$1" DCPORT="$1"
DCSERVER="$2" DCSERVER="$2"
DCTARGET="$3" DCTARGET="$3"
@ -561,25 +564,17 @@ then
fi fi
done done
IFS="$OIFS" IFS="$OIFS"
fi fi
}
# "$@" passes every parameter seperately quoted, "$*" passes all parameters as one quoted parameter. # temp function to contain all script core engine pieces until they are broken into real functions
get_parameters "$@" main_temp_engine()
{
# If no colorscheme was set in the parameter handling routine, then set the default scheme
if ! ((CSCHEME))
then
set_color_scheme "$DEFAULT_SCHEME"
fi
ALLUP=1
script_debugger "ALLUP=1 : inxi up and running.."
HN=$(hostname)
unset DISTRO unset DISTRO
shopt -s nullglob shopt -s nullglob
cd /etc; DISTGLOB=(*[-_]{release,version}) cd /etc
DISTGLOB=(*[-_]{release,version})
cd "$OLDPWD" cd "$OLDPWD"
shopt -u nullglob shopt -u nullglob
@ -1152,9 +1147,42 @@ else # (IF VBL > 1 ... ELSE)
print_screen_output "$LNSHORT" print_screen_output "$LNSHORT"
fi # (IF VBL > 1) fi # (IF VBL > 1)
## end main_temp_engine
}
########################################################################
#### SCRIPT EXECUTION
########################################################################
# Check for dependencies before running any commands in this script! So yes, here!!
check_script_depends
set_calculated_variables
get_start_app
# "$@" passes every parameter separately quoted, "$*" passes all parameters as one quoted parameter.
get_parameters "$@"
# If no colorscheme was set in the parameter handling routine, then set the default scheme
if ! ((CSCHEME))
then
set_color_scheme "$DEFAULT_SCHEME"
fi
set_konvi
script_debugger "ALLUP=1 : inxi up and running.."
# we'll pull these features out one by one and make them into real functions
main_temp_engine
## last steps
if ((IBSHELL && SCHEME)) if ((IBSHELL && SCHEME))
then then
echo -n "" echo -n ""
fi fi
exit 0 # weechat's executor plugin forced me to do this, and rightfully so, because else the exit code from the last command is taken.. exit 0 # weechat's executor plugin forced me to do this, and rightfully so, because else the exit code from the last command is taken..