mirror of
https://github.com/smxi/inxi.git
synced 2024-11-17 00:31:19 +00:00
version upgrade
some optimizations, code fixes, handled failed xargs -l case for optical disks
This commit is contained in:
parent
f02a64561c
commit
1635966093
20
inxi
20
inxi
|
@ -1,9 +1,9 @@
|
|||
#!/bin/bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### version: 1.7.0
|
||||
#### version: 1.7.1
|
||||
#### Date: June 17 2011
|
||||
#### Patch Number: 05
|
||||
#### Patch Number: 00
|
||||
########################################################################
|
||||
#### SPECIAL THANKS
|
||||
########################################################################
|
||||
|
@ -4504,21 +4504,23 @@ get_optical_drive_data()
|
|||
{
|
||||
eval $LOGFS
|
||||
|
||||
local temp_array='' sys_uevent_path='' proc_cdrom='' link_list='' dev_disks_real=''
|
||||
local temp_array='' sys_uevent_path='' proc_cdrom='' link_list=''
|
||||
local separator='' linked='' disk='' item_string='' proc_info_string=''
|
||||
local dev_disks_links="$( ls /dev/dvd* /dev/cd* /dev/scd* 2>/dev/null )"
|
||||
# get the actual disk dev location, first try default which is easier to run
|
||||
dev_disks_real="$( echo "$dev_disks_links" | xargs -l readlink 2>/dev/null | sort -u )"
|
||||
# get the actual disk dev location, first try default which is easier to run, need to preserve line breaks
|
||||
local dev_disks_real="$( echo "$dev_disks_links" | xargs -l readlink 2>/dev/null | sort -u )"
|
||||
# Some systems don't support xargs -l so we need to do it manually
|
||||
if [[ -z $dev_disks_real ]];then
|
||||
for linked in $dev_disks_links
|
||||
do
|
||||
disk=$( readlink $linked 2>/dev/null )
|
||||
if [[ -n $disk ]] && [[ -z $dev_disks_real || -z $( grep $disk <<< $dev_disks_real ) ]];then
|
||||
if [[ -n $disk ]];then
|
||||
disk=$( basename $disk ) # puppy shows this as /dev/sr0, not sr0
|
||||
# need line break IFS for below, no white space
|
||||
dev_disks_real="$dev_disks_real$separator$disk"
|
||||
separator=$'\n'
|
||||
if [[ -z $dev_disks_real || -z $( grep $disk <<< $dev_disks_real ) ]];then
|
||||
# need line break IFS for below, no white space
|
||||
dev_disks_real="$dev_disks_real$separator$disk"
|
||||
separator=$'\n'
|
||||
fi
|
||||
fi
|
||||
done
|
||||
dev_disks_real="$( sort -u <<< "$dev_disks_real" )"
|
||||
|
|
Loading…
Reference in a new issue