merge_file()
{
flag=0
-while read line_merge
+while read -r line_merge
do
if [[ flag -eq 0 ]]
then
then
flag=0
else
- echo $line_merge >> "$2"
+ echo "$line_merge" >> "$2"
fi
fi
done < "$1"
tmp_file=$(mktemp)
-while read line_main
+while read -r line_main
do
if [[ $line_main =~ "</keyword_tree>" ]]
then
- merge_file "$config_merge" "$tmp_file"
+ merge_file "$config_merge" "$tmp_file"
fi
echo "$line_main" >> "$tmp_file"
done < "$config_main"
zenity --question --text="Backup configuration file before overwriting?"
if [[ $? -eq 0 ]]
then
- cp "$config_main" "$config_main""."$(date +%Y%m%d%H%M%S)
+ cp "$config_main" "$config_main.$(date +%Y%m%d%H%M%S)"
fi
mv "$tmp_file" "$config_main"
# This needs to be run only when the menus have changed.
tmp_file=$(mktemp)
-path=$(dirname $(realpath $0))
-srcpath=$(dirname $path)"/src/layout_util.c"
-templatepath=$(dirname $path)"/plugins/template.desktop.in"
+path=$(dirname "$(realpath "$0")")
+srcpath=$(dirname "$path")/src/layout_util.c
+templatepath=$(dirname "$path")/plugins/template.desktop.in
-awk -v src_path=$srcpath 'BEGIN {
+awk -v src_path="$srcpath" 'BEGIN {
menu_flag = 0
template_flag = 0
i = 0
/Valid sections/ {template_flag = 1; print; get_menus()}
/This is a filter/ {template_flag = 0; print ""}
(template_flag == 0) {print}
-' $templatepath > $tmp_file
+' "$templatepath" > "$tmp_file"
-zenity --text-info < $tmp_file
-if [ $? == 0 ]
+zenity --text-info < "$tmp_file"
+if [ "$?" == 0 ]
then
- mv $tmp_file $templatepath
+ mv "$tmp_file" "$templatepath"
else
- rm $tmp_file
+ rm "$tmp_file"
fi