debug effort 1

This commit is contained in:
inxi-svn 2008-12-15 00:09:10 +00:00
parent 2a976358b3
commit 44b83d0e2f

70
inxi
View file

@ -1,8 +1,8 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 0.8.5-b1-t10
#### Date: December 12 2008
#### version: 0.8.8-b1-t1
#### Date: December 14 2008
########################################################################
#### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif
#### As time permits functionality improvements and recoding will occur.
@ -101,6 +101,7 @@ A_AUDIO_DATA=''
A_CMDL=''
A_CPU_CORE_DATA=''
A_CPU_DATA=''
A_DEBUG_BUFFER=''
A_GFX_CARD_DATA=''
A_GLX_DATA=''
A_HDD_DATA=''
@ -110,9 +111,6 @@ A_PARTITION_DATA=''
A_X_DATA=''
### Boolean true/false globals
# check to make sure initial steps run without error for debugging
# inxi hasn't been 'booted' yet.
B_ALL_UP='false'
# flag to allow distro maintainers to turn off update features. If false, turns off
# -U and -! testing/advanced update options, as well as removing the -U help menu item
B_ALLOW_UPDATE='true'
@ -127,6 +125,8 @@ B_SHOW_DISK='false'
B_HANDLE_CORRUPT_DATA='false'
# Running in a shell? Defaults to false, and is determined later.
B_RUNNING_IN_SHELL='false'
# this sets the debug buffer
B_SCRIPT_UP='false'
# Show sound card data
B_SHOW_AUDIO='false'
B_SHOW_CPU='false'
@ -306,33 +306,37 @@ error_handler()
exit $1
}
# args: $1 - $@ debugging string text; $2 - optional: type
# prior to script up set, pack the data into an array
# then we'll print it out later.
# args: $1 - $@ debugging string text
script_debugger()
{
local a_debug_buffer=''
print_screen_output "debugger gets this: $1"
if [[ $B_ALL_UP == 'true' || $2 == 'missing-app' ]];then
# only return if not app missing or no debugger
if [[ $DEBUG -eq 0 && $2 != 'missing-app' ]];then
return
fi
print_screen_output "we in front of the dbi loop"
if [[ $DEBUG_BUFFER_INDEX -gt 0 ]];then
for (( DEBUG_BUFFER_INDEX=0; DEBUG_BUFFER_INDEX < ${#a_debug_buffer[@]}; DEBUG_BUFFER_INDEX++ ))
if [[ $B_SCRIPT_UP == 'true' ]];then
# only return if debugger is off and no pre start up errors have occured
if [[ $DEBUG -eq 0 && $DEBUG_BUFFER_INDEX -eq 0 ]];then
return 0
# print out the stored debugging information if errors occured
elif [[ $DEBUG_BUFFER_INDEX -gt 0 ]];then
for (( DEBUG_BUFFER_INDEX=0; DEBUG_BUFFER_INDEX < ${#A_DEBUG_BUFFER[@]}; DEBUG_BUFFER_INDEX++ ))
do
print_screen_output "${a_debug_buffer[$DEBUG_BUFFER_INDEX]}"
print_screen_output "${A_DEBUG_BUFFER[$DEBUG_BUFFER_INDEX]}"
done
DEBUG_BUFFER_INDEX=0
fi
print_screen_output "we got past the dbi loop"
print_screen_output "$@"
# or print out normal debugger messages if debugger is on
if [[ $DEBUG -gt 0 ]];then
print_screen_output "$1"
fi
else
if [[ $B_DEBUG_FLOOD == 'true' && $DEBUG_BUFFER_INDEX -gt 10 ]];then
error_handler 2
# this case stores the data for later printout, will print out only
# at B_SCRIPT_UP == 'true' if array index > 0
else
A_DEBUG_BUFFER[$DEBUG_BUFFER_INDEX]="$1"
# increment count for next pre script up debugging error
(( DEBUG_BUFFER_INDEX++ ))
fi
a_debug_buffer[DEBUG_BUFFER_INDEX++]="$@"
fi
}
@ -432,7 +436,7 @@ check_script_depends()
do
app_data=$( type -p $app_name )
if [[ -z $app_data ]];then
script_debugger "Resuming in non X mode: $app_name not found in path" 'missing-app'
script_debugger "Resuming in non X mode: $app_name not found in path"
B_X_RUNNING='false'
break
fi
@ -2700,13 +2704,21 @@ print_system_data()
########################################################################
#### SCRIPT EXECUTION
########################################################################
# first two functions must be set first for colors etc. Remember, no debugger
# stuff works on these first two functions unless you set the debugging flag
# manually. Debugging flag -@ [number] will not work until get_parameters runs.
set_calculated_variables
# Check for dependencies before running anything else except above function
check_script_depends
## this needs to run before the KONVI stuff is set below
get_start_client
# "$@" passes every parameter separately quoted, "$*" passes all parameters as one quoted parameter.
# must be here to allow debugger and other flags to be set.
get_parameters $@
# Check for dependencies before running anything else except above functions
check_script_depends
# note: this only works if it's run from inside konversation as a script builtin or something
# only do this if inxi has been started as a konversation script, otherwise bypass this
if [[ $KONVI -eq 1 ]];then
@ -2731,17 +2743,15 @@ fi
# print_screen_output "DCSERVER: $DCSERVER"
# print_screen_output "DCTARGET: $DCTARGET"
# "$@" 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 [[ $COLOR_SCHEME_SET != 'true' ]];then
set_color_scheme "$DEFAULT_SCHEME"
fi
# all the pre-start stuff is in place now
B_ALL_UP='true'
script_debugger "Debugger: inxi up and running.."
B_SCRIPT_UP='true'
script_debugger "Debugger: $SCRIPT_NAME is up and running..."
# then create the output
print_it_out