mirror of
https://github.com/smxi/inxi.git
synced 2024-11-17 00:31:19 +00:00
Added which sudo test, added more comments to explain what is happening.
This commit is contained in:
parent
042cd2cd65
commit
fcc98e7c11
5
inxi
5
inxi
|
@ -2608,10 +2608,11 @@ get_hdd_temp_data()
|
|||
if [[ -n $( which hddtemp ) && -n $1 ]];then
|
||||
# only use sudo if not root, -n option requires sudo -V 1.7 or greater. sudo will just error out
|
||||
# which is the safest course here for now, otherwise that interactive sudo password thing is too annoying
|
||||
if [[ $B_ROOT != 'true' ]];then
|
||||
# important: -n makes it non interactive, no prompt for password
|
||||
if [[ $B_ROOT != 'true' && -n $( which sudo ) ]];then
|
||||
sudo_command='sudo -n '
|
||||
fi
|
||||
# important: -n makes it non interactive, no prompt for password
|
||||
# this will fail if regular user and no sudo present, but that's fine, it will just return null
|
||||
hdd_temp=$( eval $sudo_command hddtemp -nq -u C $1 )
|
||||
if [[ -n $hdd_temp && -n $( grep -E '^([0-9]+)$' <<< $hdd_temp ) ]];then
|
||||
echo $hdd_temp
|
||||
|
|
Loading…
Reference in a new issue