fixed logic error in config file check/creation

This commit is contained in:
inxi-svn 2011-04-26 19:50:18 +00:00
parent 9e5426b180
commit 493f36bab3

8
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 1.4.85
#### version: 1.4.86
#### Date: April 26 2011
########################################################################
#### SPECIAL THANKS
@ -905,16 +905,18 @@ select_default_color_scheme()
;;
esac
set_color_scheme $user_selection
if [[ ! -f $config_file || -z $( grep -s "$config_variable=" $config_file ) ]];then
# make file/directory first if missing
if [[ ! -f $config_file ]];then
if [[ ! -d $HOME/.$SCRIPT_NAME ]];then
mkdir $HOME/.$SCRIPT_NAME
fi
touch $config_file
fi
if [[ -z $( grep -s "$config_variable=" $config_file ) ]];then
print_screen_output "Creating and updating config file for $COLOR_SELECTION color scheme now..."
echo "$config_variable=$user_selection" >> $config_file
else
print_screen_output "Updating config file for $COLOR_SELECTION color scheme now..."
touch $config_file # just in case of logic error above
sed -i "s/$config_variable=.*/$config_variable=$user_selection/" $config_file
fi
# file exists now so we can go on to cleanup