Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/functions/cli/utils-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function apply_cmdline_params_to_env() {
if [[ -z "${!param_name+x}" ]] || [[ "${current_env_value}" != "${param_value}" ]]; then
display_alert "Applying cmdline param" "'$param_name': '${current_env_value_desc}' --> '${param_value_desc}' ${__my_reason}" "cmdline"
# use `declare -g` to make it global, we're in a function.
eval "declare -g $param_name=\"$param_value\""
declare -g "${param_name}=${param_value}"
else
# rpardini: strategic amount of spacing in log files show the kinda neuroticism that drives me.
display_alert "Skip cmdline param" "'$param_name': already set to '${param_value_desc}' ${__my_reason}" "info"
Expand Down
8 changes: 7 additions & 1 deletion lib/functions/configuration/change-tracking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ function track_config_variables() {

# if the var is an array...
if [[ "${array_values:-"no"}" == "yes" ]]; then
eval "var_value=\"\${${var_name}[@]}\"" # sorry
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment tells me that Ricardo put some thought into this before leaving as it is. So I'd like to hear his opinion on the change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# bash nameref (local -n) creates an alias for the variable named in $var_name —
# no eval needed, no code-injection risk. Works for arrays and scalars alike.
# unset -n removes the alias only (not the referenced array) to avoid
# "already a nameref" warnings on the next loop iteration.
local -n _ct_arr_ref="${var_name}"
var_value="${_ct_arr_ref[*]}"
unset -n _ct_arr_ref
value_text="${blue_color:-}(${bright_blue_color:-}${var_value}${blue_color:-})"
else
var_value="${!var_name}"
Expand Down
4 changes: 2 additions & 2 deletions lib/functions/configuration/interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function interactive_config_prepare_terminal() {
# $1: variable name
# $2: variable value
function set_interactive_config_value() {
eval "$1"='$2'
eval "ARMBIAN_INTERACTIVE_CONFIGS[${1}]"='$2'
declare -g "${1}=${2}"
ARMBIAN_INTERACTIVE_CONFIGS["${1}"]="${2}"
}

function interactive_finish() {
Expand Down