Can I get rid of eval here? I’m trying to set $current_database with the appropriate variable determined by user input (country and action)
# User input
country="es"
action="sales"
# Possible variables for current_database
final_es_sales_path="blahblah/es/sales.csv"
final_en_support_path="yadayada/en/support.csv"
final_it_inventory_path="humhum/it/inventory.csv"
...
current_database=$(eval echo \${final_${country}_${action}_path})
You can use associative arrays, joining the value of both variables. For example:
Then, you can get the database just by:
This has the advantage of having the database names collected by only one variable.