From f66a09d3788d11454ac9723dc897188ccbbf9ed1 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 17 Apr 2017 15:27:54 +0200 Subject: [PATCH] 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. --- config | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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]}" -- 2.39.2