(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

36
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.5.17 #### version: 0.5.18
#### Date: November 11 2008 #### Date: November 11 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
@ -493,17 +493,16 @@ get_cmdline()
get_parameters() get_parameters()
{ {
local opt='' wget_test='' 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. # the short form only runs if no args output args are used
# note: for future fixing, this fails if debugger -@ option is used, this should be fixed someday # no need to run through these if there are no args
if [[ -z $1 ]];then if [[ -n $1 ]];then
B_SHOW_SHORT_OUTPUT='true'
fi
while getopts Ac:CdDfFGhHINPSUv:Vx%@:!: opt while getopts Ac:CdDfFGhHINPSUv:Vx%@:!: opt
do do
case $opt in case $opt in
A) B_SHOW_AUDIO='true' A) B_SHOW_AUDIO='true'
use_short='false'
;; ;;
c) if [[ -n $( egrep '^[0-9][0-9]?$' <<< $OPTARG ) ]];then c) if [[ -n $( egrep '^[0-9][0-9]?$' <<< $OPTARG ) ]];then
COLOR_SCHEME_SET='true' COLOR_SCHEME_SET='true'
@ -517,13 +516,17 @@ get_parameters()
fi fi
;; ;;
C) B_SHOW_CPU='true' C) B_SHOW_CPU='true'
use_short='false'
;; ;;
d) VERBOSITY_LEVEL=1 d) VERBOSITY_LEVEL=1
use_short='false'
;; ;;
D) B_SHOW_DISK='true' D) B_SHOW_DISK='true'
use_short='false'
;; ;;
f) B_SHOW_CPU='true' f) B_SHOW_CPU='true'
B_CPU_FLAGS_FULL='true' B_CPU_FLAGS_FULL='true'
use_short='false'
;; ;;
F) VERBOSITY_LEVEL=$VERBOSITY_LEVELS F) VERBOSITY_LEVEL=$VERBOSITY_LEVELS
B_CPU_FLAGS_FULL='true' B_CPU_FLAGS_FULL='true'
@ -531,21 +534,31 @@ get_parameters()
B_SHOW_DISK='true' B_SHOW_DISK='true'
B_SHOW_PARTITIONS='true' B_SHOW_PARTITIONS='true'
B_SHOW_AUDIO='true' B_SHOW_AUDIO='true'
use_short='false'
;; ;;
G) B_SHOW_GRAPHICS='true' G) B_SHOW_GRAPHICS='true'
use_short='false'
;; ;;
H) B_SHOW_HDD_FULL='true' H) B_SHOW_HDD_FULL='true'
use_short='false'
;; ;;
I) B_SHOW_INFO='true' I) B_SHOW_INFO='true'
use_short='false'
;; ;;
N) B_SHOW_NETWORK='true' N) B_SHOW_NETWORK='true'
use_short='false'
;; ;;
P) B_SHOW_PARTITIONS='true' P) B_SHOW_PARTITIONS='true'
use_short='false'
;; ;;
S) B_SHOW_SYSTEM='true' S) B_SHOW_SYSTEM='true'
use_short='false'
;; ;;
v) if [[ -n $( egrep "^[0-9][0-9]?$" <<< $OPTARG ) && $OPTARG -le $VERBOSITY_LEVELS ]];then v) if [[ -n $( egrep "^[0-9][0-9]?$" <<< $OPTARG ) && $OPTARG -le $VERBOSITY_LEVELS ]];then
VERBOSITY_LEVEL="$OPTARG" VERBOSITY_LEVEL="$OPTARG"
if [[ $OPTARG -gt 0 ]];then
use_short='false'
fi
else else
error_handler 4 "$OPTARG" error_handler 4 "$OPTARG"
fi fi
@ -594,12 +607,18 @@ get_parameters()
;; ;;
esac esac
done done
fi
## this must occur here so you can use the debugging flag to show errors ## this must occur here so you can use the debugging flag to show errors
## Reroute all error messages to the bitbucket (if not debugging) ## Reroute all error messages to the bitbucket (if not debugging)
if [[ $DEBUG -eq 0 ]];then if [[ $DEBUG -eq 0 ]];then
exec 2>/dev/null exec 2>/dev/null
fi fi
#((DEBUG)) && exec 2>&1 # This is for debugging konversation #((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 ## 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 "-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 "-S Show system information: host name, kernel, distro"
print_screen_output "-v Script verbosity levels. Verbosity level number is required." 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 " 1 - basic verbose, same as: $SCRIPT_NAME -d"
print_screen_output " 2 - Also show networking card data" print_screen_output " 2 - Also show networking card data"
print_screen_output " 3 - Also show hard disk names as detected." print_screen_output " 3 - Also show hard disk names as detected."