From fcc98e7c111579aace0c11ca0aec2556e5c6255d Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Mon, 3 Aug 2009 04:38:27 +0000 Subject: [PATCH] Added which sudo test, added more comments to explain what is happening. --- inxi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inxi b/inxi index bfc37be..7dffe99 100755 --- a/inxi +++ b/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