From: Andre Noll Date: Mon, 17 Apr 2017 13:27:54 +0000 (+0200) Subject: config: Declare local config variables earlier. X-Git-Url: http://git.tuebingen.mpg.de/?p=gsu.git;a=commitdiff_plain;h=f66a09d3788d11454ac9723dc897188ccbbf9ed1;ds=sidebyside config: Declare local config variables earlier. In gsu_check_options() we declare the six option variables (name, option_type, ...) local to avoid overwriting the content of user-defined variables of the same name. Of course this only works if the variables are declared local before we assign to them. This is currently not the case because the eval "${gsu_options[$i]}" statement in the first loop sets these variables before they are declared in the body of the second loop. This bug is benign since gsu_check_options() is usually called before any command handler is executed. Let's fix it anyway. --- diff --git a/config b/config index 4e731af..6b3be62 100644 --- a/config +++ b/config @@ -6,7 +6,8 @@ # file. gsu_check_options() { - local i conf="${gsu_config_file:=${HOME:-}/.$gsu_name.rc}" val + local i conf="${gsu_config_file:=${HOME:-}/.$gsu_name.rc}" val orig_val + local name option_type default_value required description help_text for ((i=0; i < ${#gsu_options[@]}; i++)); do eval "${gsu_options[$i]}" @@ -17,9 +18,12 @@ gsu_check_options() [[ -r "$conf" ]] && source "$conf" for ((i=0; i < ${#gsu_options[@]}; i++)); do - local name= option_type= default_value= required= - local description= help_text= - local val orig_val + name= + option_type= + default_value= + required= + description= + help_text= eval "${gsu_options[$i]}"