diff --git a/misc/build.func b/misc/build.func index 3a7b8c0a7..558331669 100644 --- a/misc/build.func +++ b/misc/build.func @@ -588,6 +588,12 @@ load_vars_file() { [[ "$var_key" != var_* ]] && continue _is_whitelisted "$var_key" || continue + # Strip inline comments (anything after unquoted #) + # Only strip if not inside quotes + if [[ ! "$var_val" =~ ^[\"\'] ]]; then + var_val="${var_val%%#*}" + fi + # Strip quotes if [[ "$var_val" =~ ^\"(.*)\"$ ]]; then var_val="${BASH_REMATCH[1]}" @@ -595,6 +601,9 @@ load_vars_file() { var_val="${BASH_REMATCH[1]}" fi + # Trim trailing whitespace + var_val="${var_val%"${var_val##*[![:space:]]}"}" + # Set variable: force mode overrides existing, otherwise only set if empty if [[ "$force" == "yes" ]]; then export "${var_key}=${var_val}"