(Change Version)

Fixed a fairly major bug with both short output handling and debugging output
in get_parameters.

Prevented proper handling of non line/F/d/v type options and short output.

Update scripts to this version, and hopefully that will be it for now.
This commit is contained in:
inxi-svn 2008-11-12 01:39:27 +00:00
parent be6d736498
commit 3688020946

220
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 0.5.17
#### version: 0.5.18
#### Date: November 11 2008
########################################################################
#### inxi is a fork of infobash, the original bash sys info script by locsmif
@ -493,113 +493,132 @@ get_cmdline()
get_parameters()
{
local opt='' wget_test=''
local use_short='true' # this is needed to trigger short output, every v/d/F/line trigger sets this false
# the short form only runs if no args are used, otherwise a line or verbose output is given.
# note: for future fixing, this fails if debugger -@ option is used, this should be fixed someday
if [[ -z $1 ]];then
B_SHOW_SHORT_OUTPUT='true'
fi
while getopts Ac:CdDfFGhHINPSUv:Vx%@:!: opt
do
case $opt in
A) B_SHOW_AUDIO='true'
;;
c) if [[ -n $( egrep '^[0-9][0-9]?$' <<< $OPTARG ) ]];then
COLOR_SCHEME_SET='true'
## note: not sure about this, you'd think user values should be overridden, but
## we'll leave this for now
if [[ -z $COLOR_SCHEME ]];then
set_color_scheme "$OPTARG"
fi
else
error_handler 3 "$OPTARG"
fi
;;
C) B_SHOW_CPU='true'
;;
d) VERBOSITY_LEVEL=1
;;
D) B_SHOW_DISK='true'
;;
f) B_SHOW_CPU='true'
B_CPU_FLAGS_FULL='true'
;;
F) VERBOSITY_LEVEL=$VERBOSITY_LEVELS
B_CPU_FLAGS_FULL='true'
B_EXTRA_DATA='true'
B_SHOW_DISK='true'
B_SHOW_PARTITIONS='true'
B_SHOW_AUDIO='true'
;;
G) B_SHOW_GRAPHICS='true'
;;
H) B_SHOW_HDD_FULL='true'
;;
I) B_SHOW_INFO='true'
;;
N) B_SHOW_NETWORK='true'
;;
P) B_SHOW_PARTITIONS='true'
;;
S) B_SHOW_SYSTEM='true'
;;
v) if [[ -n $( egrep "^[0-9][0-9]?$" <<< $OPTARG ) && $OPTARG -le $VERBOSITY_LEVELS ]];then
VERBOSITY_LEVEL="$OPTARG"
else
error_handler 4 "$OPTARG"
fi
;;
U) script_self_updater "$SCRIPT_DOWNLOAD" 'svn server'
;;
V) print_version_info
exit 0
;;
x) B_EXTRA_DATA='true'
;;
h|H) show_options
exit 0
;;
## debuggers and testing tools
%) B_HANDLE_CORRUPT_DATA='true'
echo it is $opt
;;
@) if [[ -n $( egrep "^([1-9]|10)$" <<< $OPTARG ) ]];then
DEBUG=$OPTARG
exec 2>&1
else
error_handler 9 "$OPTARG"
fi
;;
!) # test for various supported methods
case $OPTARG in
1) B_TESTING_FLAG='true'
;;
2) script_self_updater "$SCRIPT_DOWNLOAD_DEV" 'dev server'
;;
http*)
# first test provided url to avoid overwriting file with null
wget -q --spider "$OPTARG$SCRIPT_NAME"
if [[ $? -eq 0 ]];then
script_self_updater "$OPTARG" 'alt server'
else
error_handler 10 "$OPTARG"
# the short form only runs if no args output args are used
# no need to run through these if there are no args
if [[ -n $1 ]];then
while getopts Ac:CdDfFGhHINPSUv:Vx%@:!: opt
do
case $opt in
A) B_SHOW_AUDIO='true'
use_short='false'
;;
c) if [[ -n $( egrep '^[0-9][0-9]?$' <<< $OPTARG ) ]];then
COLOR_SCHEME_SET='true'
## note: not sure about this, you'd think user values should be overridden, but
## we'll leave this for now
if [[ -z $COLOR_SCHEME ]];then
set_color_scheme "$OPTARG"
fi
;;
*) error_handler 11 "$OPTARG"
;;
else
error_handler 3 "$OPTARG"
fi
;;
C) B_SHOW_CPU='true'
use_short='false'
;;
d) VERBOSITY_LEVEL=1
use_short='false'
;;
D) B_SHOW_DISK='true'
use_short='false'
;;
f) B_SHOW_CPU='true'
B_CPU_FLAGS_FULL='true'
use_short='false'
;;
F) VERBOSITY_LEVEL=$VERBOSITY_LEVELS
B_CPU_FLAGS_FULL='true'
B_EXTRA_DATA='true'
B_SHOW_DISK='true'
B_SHOW_PARTITIONS='true'
B_SHOW_AUDIO='true'
use_short='false'
;;
G) B_SHOW_GRAPHICS='true'
use_short='false'
;;
H) B_SHOW_HDD_FULL='true'
use_short='false'
;;
I) B_SHOW_INFO='true'
use_short='false'
;;
N) B_SHOW_NETWORK='true'
use_short='false'
;;
P) B_SHOW_PARTITIONS='true'
use_short='false'
;;
S) B_SHOW_SYSTEM='true'
use_short='false'
;;
v) if [[ -n $( egrep "^[0-9][0-9]?$" <<< $OPTARG ) && $OPTARG -le $VERBOSITY_LEVELS ]];then
VERBOSITY_LEVEL="$OPTARG"
if [[ $OPTARG -gt 0 ]];then
use_short='false'
fi
else
error_handler 4 "$OPTARG"
fi
;;
U) script_self_updater "$SCRIPT_DOWNLOAD" 'svn server'
;;
V) print_version_info
exit 0
;;
x) B_EXTRA_DATA='true'
;;
h|H) show_options
exit 0
;;
## debuggers and testing tools
%) B_HANDLE_CORRUPT_DATA='true'
echo it is $opt
;;
@) if [[ -n $( egrep "^([1-9]|10)$" <<< $OPTARG ) ]];then
DEBUG=$OPTARG
exec 2>&1
else
error_handler 9 "$OPTARG"
fi
;;
!) # test for various supported methods
case $OPTARG in
1) B_TESTING_FLAG='true'
;;
2) script_self_updater "$SCRIPT_DOWNLOAD_DEV" 'dev server'
;;
http*)
# first test provided url to avoid overwriting file with null
wget -q --spider "$OPTARG$SCRIPT_NAME"
if [[ $? -eq 0 ]];then
script_self_updater "$OPTARG" 'alt server'
else
error_handler 10 "$OPTARG"
fi
;;
*) error_handler 11 "$OPTARG"
;;
esac
;;
*) error_handler 7 "$1"
;;
esac
;;
*) error_handler 7 "$1"
;;
esac
done
done
fi
## this must occur here so you can use the debugging flag to show errors
## Reroute all error messages to the bitbucket (if not debugging)
if [[ $DEBUG -eq 0 ]];then
exec 2>/dev/null
fi
#((DEBUG)) && exec 2>&1 # This is for debugging konversation
# after all the args have been processed, if no long output args used, run short output
if [[ $use_short == 'true' ]];then
B_SHOW_SHORT_OUTPUT='true'
fi
}
## print out help menu, not including Testing or Debugger stuff because it's not needed
@ -631,7 +650,8 @@ show_options()
print_screen_output "-P Show partition information (shows what -v4 would show, but without extra data)."
print_screen_output "-S Show system information: host name, kernel, distro"
print_screen_output "-v Script verbosity levels. Verbosity level number is required."
print_screen_output " Supported levels: 1-${VERBOSITY_LEVELS} Example: $SCRIPT_NAME -v 4"
print_screen_output " Supported levels: 0-${VERBOSITY_LEVELS} Example: $SCRIPT_NAME -v 4"
print_screen_output " 0 - short output, same as: $SCRIPT_NAME"
print_screen_output " 1 - basic verbose, same as: $SCRIPT_NAME -d"
print_screen_output " 2 - Also show networking card data"
print_screen_output " 3 - Also show hard disk names as detected."